Thoughts and updates on open-source programming, C++, and GNOME

Tuesday, May 29, 2007

Publishing Git Repositories

Dear Lazyweb,

I've been using git for a while for most of my projects, and I love it. It's fast, powerful, and it's actually quite simple to use. Whenever I start hacking on something, even if it's just a little utility that will never see the light of day, I generally initialize a git repo and hack in there.

But my question is, what do I do if I want to make that repository public? I want to create a 'bare' repository (e.g. without any working directory files) on a public server that I can push to, and that others can pull from and push to. I would have expected some command like git clone --bare ./local-repo ssh://remote-server/remote-repo, but that doesn't seem to work. Am I overlooking something obvious?


At 29/5/07 4:03 PM, Blogger anholt said...

anholt@vonnegut:/home/anholt/mesa% ssh
anholt@annarchy:/home/anholt% mkdir mesa.git
anholt@annarchy:/home/anholt% cd mesa.git
anholt@annarchy:/home/anholt/mesa.git% GIT_DIR=. git-init-db
anholt@annarchy:/home/anholt/mesa.git% touch git-daemon-export-ok
anholt@annarchy:/home/anholt/mesa.git% emacs description
anholt@annarchy:/home/anholt/mesa.git% exit
anholt@vonnegut:/home/anholt/mesa% git-push git+ssh:// master:master

At 29/5/07 4:15 PM, Blogger Emmanuele said...

don't forget:

chmod +x repo.git/hooks/post-update

so that the index is updated with every push.

At 29/5/07 4:18 PM, Anonymous Anonymous said...

Eric's way will definitely work, but you almost had the clone right.

$ git clone --bare $remoterepo $localdir

I think you just had the last two args reversed.

At 29/5/07 4:43 PM, Blogger Jonner said...

anonymous: I intentionally reversed the last two arguments of 'git clone' because I want to initialize a public remote git repo from my local git repo. Reversing the arguments as you suggest only works if you want to clone a public git repo into a local git repo, which is the opposite of what I'm trying to do.

At 29/5/07 4:56 PM, Blogger Jonner said...

anholt: thanks, that's a lot better than the only thing I could figure out, which was essentially:
scp local-repo remote-server/remote-repo
mv local-repo local-repo.bak
git clone remote-server/remote-repo local-repo
# verify everything's ok
rm -rf local-repo.bak

But it still seems like a lot of manual work. I had assumed there would be a more automated way to do this, but if not, oh well.

At 29/5/07 5:11 PM, Blogger rob said...

If you've got git on the remote machine, then you could replace the scp with a git-clone --bare pointing back at your local repository. The advantage being that it's a bare repository, and I guess you end up transferring less data.

At 29/5/07 5:49 PM, Anonymous Anonymous said...

At 29/5/07 5:57 PM, Blogger Jonner said...

Aha! So there *is* some official documentation on the subject. I had looked and looked but couldn't find anything about it. Thank you very much for that link. This lazyweb thing is pretty impressive :)

At 6/10/07 11:56 PM, Anonymous Anonymous said...



Post a Comment

<< Home