Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add/commit a file to the index of a local bare Git repo?

Tags:

git

grit

I'm messing around with the Ruby Git gem... seeing how I can use it to manage/access a Gitosis server I'm running. Does anyone know if it is possible to add/commit files to a local bare repo, or will I need to set up a local 'normal' repo and use SSH to push it to the bare repo on the localhost?

like image 888
Bryan Avatar asked Dec 16 '22 15:12

Bryan


2 Answers

You should be able to do this using low level plumbing commands:

$ generate_contents | git hash-object -t blob -w --stdin
$ git update-index --cacheinfo 100644 sha1 path
  • sha1 is result of previous command.
  • 100644: means an ordinary file.

But bare repositories are meant to be used only to push into or fetch from. Bare repository doesn't need to have index at all!

like image 100
Jakub Narębski Avatar answered Dec 19 '22 08:12

Jakub Narębski


You need a working tree to add a file to the index and commit it.
While it might be possible to change directly the internal content of a bare git repo through plumbing commands, I would really recommend setting up a normal clone, modify it and push the resulting commit back to the bare repo.

like image 37
VonC Avatar answered Dec 19 '22 08:12

VonC