newsGNU Scientific Library - News

 
 

Simple Git repository publication

Item posted by -Deleted Account- <bjg> on Sun 26 Oct 2008 08:52:22 PM UTC.

If you are working on changes to a project using Git, such as GSL, it can be useful to make your repository public rather than sending patches.

The usual way to export a git branch involves running git-daemon, webdav or having git installed on the web server.  However, it is also possible to export your repository  simply by copying the .git directory to a web server.  There are some limitations---your whole repository is exported, not just a specific branch, and you must run git-update-server-info each time before copying the files.

Directory index pages need to be enabled the web server---when a git client accesses your repository over http it needs to get a list of the files in each directory.  With Apache this requires
   

Options +Indexes


You can then copy your repository to the web server:
   

$ git-update-server-info
$ rsync -vazP .git/ remotehost:/var/www/myrepo


Run these commands each time you want to export the repository e.g. after making some changes and committing them.  Note the trailing slash on .git/ to copy the contents of the directory, rather than the directory itself.  Both commands are needed, you can put them together in a script or add the command git-update-server-info to .git/hooks/post-commit and make it executable.

The repository should now be accessible remotely over http:
   

$ git remote add bob http://remotehost/myrepo
$ get fetch -v bob
$ git diff bob/master


If you want to work against a remote repository you can copy it as usual to your local machine:
   

$ git clone git://git.savannah.gnu.org/gsl.git


but to save space it is also possible to make a shallow copy:
   

$ git clone --depth 1 git://git.savannah.gnu.org/gsl.git


The git documentation suggests that fetch will not work against a shallow copy, but it seems to work ok in this context.


Back to the top

Powered by Savane 3.13-02a9.
Corresponding source code