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?
anholt@vonnegut:/home/anholt/mesa% ssh people.freedesktop.org
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://people.freedesktop.org/~anholt/mesa master:master
don’t forget:
chmod +x repo.git/hooks/post-update
so that the index is updated with every push.
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.
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.
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.
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.
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#public-repositories
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 🙂