How to publish a Git repository
This post is aimed mainly at Factor developers who need to make their repository accessible to Slava to retrieve patches. Factor has recently moved to using git as the version control system.
To set up a repository on a server you should clone the existing Factor repository using the '--bare' option:
Copy the 'factor.git' directory onto your server. I put it in '/git/factor.git'. Now if you have changes on your local machine that you want to push to your repository you can use something like:
To publish via HTTP, you must make the file 'hooks/post-update' executable:
My repository is accessible from both protocols:
Categories: factor, git
To set up a repository on a server you should clone the existing Factor repository using the '--bare' option:
git clone --bare http://www.factorcode.org/git/factor.git factor.gitA bare repository is one without a checked out working copy of the code. It only contains the git database. As a general rule you should never push into a repository that contains changes in the working copy. To ensure this doesn't happen, we're making the server repository a bare repository - it has no working copy.
Copy the 'factor.git' directory onto your server. I put it in '/git/factor.git'. Now if you have changes on your local machine that you want to push to your repository you can use something like:
git push yourname@yourserver.com:/git/factor.gitIf you want to push changes from a specific branch in your local repository:
git push yourname@yourserver.com:/git/factor.git mybranch:masterTo publish the remote repository you have two options. You can publish via the HTTP protocol, or via the git protocol. The first is slower but usable by people behind restrictive firewalls, while the second is more efficient but requires an open port. I suggest doing both.
To publish via HTTP, you must make the file 'hooks/post-update' executable:
chmod +x /git/factor.git/hooks/post-updateThis gets executed whenever something is pushed to the repository. It runs a command 'git-update-server-info' which updates some files that makes the HTTP retrieval work. You should also run this once manually:
cd /git/factor.gitNow make the /git directory published via your webserver (I symbolic link to it in the server's doc-root). People can pull from the repository with:
git-update-server-info
git pull http://yourserver.com/git/factor.gitTo set up the git protocol you need to run the 'git-daemon' command. You pass it a directory which is the root of your git repositories. It will make public all git repositories underneath that root that have the file 'git-daemon-export-ok' in it. So first create this file:
touch /git/factor.git/git-daemon-export-okRun the daemon with:
git-daemon --verbose /gitThe '--verbose' will give you output showing the results of connecting to it. I run this from within a screen session. You can set it up to automatically run using whatever features your server OS has. Now people can retrieve via the git protocol:
git pull git://yourserver.com/git/factor.git
My repository is accessible from both protocols:
git clone http://www.double.co.nz/git/factor.gitYou can also browse it using gitweb.
git clone git://double.co.nz/git/factor.git
Categories: factor, git

3 Comments:
I just learnt this much about git and I was in the process of distilling to a simple process. You saved me a bunch of time. And that is the nicest thing to save. Thanks so much.
Make sure to use git 1.5 or above. The version from apt-get on Debian was too old for this to work, so I built it from scratch. And if you do that, make sure to install systemwide instead of just in your user's bin/ with sudo make prefix=/usr/ install. Also, you really do need to make a /git directory or read the docs for git-daemon. Great tutorial!
http://blog.madduck.net/vcs/2007.07.11_publishing-git-repositories
Post a Comment
<< Home