The NagVis project moved the version control system from subversion to git some days ago. In subversion we used several hooks scripts to inform developers and other platforms about our changes. Since we use a hosted git repository on sourceforge.net in this case I will describe the procedure adding git hooks for the NagVis project. For another project simply replace nagvis with your projects unix name.
You are interested? Take a look at the whole story …
I work from a linux workstation here but these steps should also work in windows when using cygwin.
Some basic information:
- Git gives you the availability to execute scripts on many actions when you like. This is realized using so called hooks. For a list of hook take a look at the git documentation. In my case I use the post-receive hook. This hook is executed on every push to the server.
- I like to send all commit mails to a mailinglist called nagvis-checkins [at] lists.sourceforge.net.
- To be able to administrate the sourceforge.net git repository you need to connect to their servers using the shell service.
- SF.net specific: The repository is locked from
adminrepo --checkout gitcommand to
adminrepo --savecommand. No one else can write the git repository.
- SF.net specific: Be carefull using the administration mode. You can destroy(!) the repository. So I admit to create a backup first.
Now let’s start…
# First create a backup rsync -av nagvis.git.sourceforge.net::gitroot/nagvis/* 2009-06-28-nagvis-git # Create a shell session and connect to the server (User: <sf.net-user>,<projectname>) ssh -t larsi-,firstname.lastname@example.org create # Mount and lock the repository adminrepo --checkout git # Change to hooks directory cd /gitroot/nagvis/hooks # Create hook file and fill with script (I took it right from the source http://git.kernel.org/?p=git/git.git;a=blob_plain;f=contrib/hooks/post-receive-email) vi post-receive # Set execute permissions chmod a+x post-receive
Now update the git configuration
Add the hooks section to the git configuration file
[hooks] mailinglist = "email@example.com" announcelist = envelopesender = emailprefix = "SF.net Git: " showrev =
Then save, unmount, unlock the repository and disconnect the sf.net server
# save, unmount, unlock adminrepo --save # Quit exit
Now test the new hook script. Simply create a new commit and push it to the server. Your list should receive a new mail.