Using Git on Alioth

Creating a new public Git repository (for a new project)

Git repository on git.debian.org doesn't get created with a new project, you have to request it at the [https://alioth.debian.org/tracker/?group_id=1&atid=200001 Tracker: Support Requests].

<!> Note: Instead of registering a separate project(s) for packages, consider using the [http://alioth.debian.org/projects/collab-maint/ Collab Maint project]; see ["Alioth/PackagingProject"] for more information. Once granted access to that project (DD have access by default, non-DD must request it) you can start hosting Git project immediately by logging into alioth.debian.org and creating a git repository under /git/collab-maint/.

For separately registered projects, the git.debian.org admins will create a directory named /git/<project-group> owned by your project group.

To initialize your remote repository, you have to run under /git/<group> (<group> can be collab-maint if you don't have a dedicated project):

$ umask 002
$ mkdir <project>.git
$ cd <project>.git
$ git --bare init --shared
$ vim description
$ chmod a+x hooks/post-update

If you're going to use collab-maint, then you can also just run the script setup-repository:

$ umask 002
$ cd /git/collab-maint
$ ./setup-repository <project> 'description'

Then you have to put some real content in that empty repository. Either git fetch/pull on git.debian.org or git push from a remote host to git.debian.org. See below for the Git URLs that you can use.

<!> Example: To create local Git repository and populate it with existing source:

$ cd /path/to/sources/<project>
$ git init
$ git add .
$ git commit -m 'Initial import of <project> version <version>'
$ git tag <version>

<!> Example: To push a project to an alioth collab-maint repository:

$ cd /path/to/<project>.git
$ git remote add alioth ssh://<user>@git.debian.org/git/collab-maint/<project>.git
$ git push alioth <branchname>
$ git push alioth --tags

Accessing repositories

They are accessible by git using sftp, rsync over ssh, or git-server/http for read-only access. Note that http://git.debian.org is only updated by cron once every 6 hours, so be patient when creating a new repository... it'll show up eventually. For instance, you'll be able to check out your branch though sftp with:

$ git clone ssh://<user>@git.debian.org/git/<group>/<project>.git

Anonymous users will enjoy read-only access with following commands. The <group> could be e.g. package name or collab-maint if hosted collaboratively.

$ git clone git://git.debian.org/git/<group>/<project>.git
$ git clone http://git.debian.org/git/<group>/<project>.git

Please use the native git protocol, because it is much more efficient than cloning over http. If your firewall restricts access to port 9418 you could clone over http. But notice that if the upstream repo on alioth is repacked, you have to download the whole objects again if you clone/fetch over http.

Repository maintenance

Git repositories tend to grow quite large quickly. From time to time, you have to repack the repositories to save space and keep optimal performances (by not having too many of files in the objects subdirectory).

$ cd /git/<group>/<project>.git
$ git repack && git gc

Those operations should be always safe (and can be ran via cron).

You can optimize even more by using some options but then people fetching over HTTP (bad idea!) might have troubles and they are not safe to run when someone else is using the repository (for example pushing new revisions). Thus don't put those commands in a cron invocation:

$ git repack -a -d && git gc --prune

Setting up hooks

Commit mails with diff

Modify the relevants values in the log below:

$ cd <project>.git
# For sending diff to a mailing list use this:
$ git config --add hooks.mailinglist "project-commit@lists.alioth.debian.org"
# For sending diff to the PTS use this:
$ git config --add hooks.bcc "package_cvs@packages.qa.debian.org"
# Create the hook
$ cat >hooks/post-receive <<END
#!/bin/sh
exec /usr/local/bin/git-commit-notice
END
$ chmod 755 hooks/post-receive

Sending notices on IRC via CIA bots

Some hooks meant for CIA are there: http://cia-vc.googlecode.com/svn/trunk/cia/htdocs/clients/git/

If you use the above git-commit-notice already, you can configure CIA simply by adding some variables:

$ cd <project>.git
# Required to activate it
$ git config --add hooks.cia-project myproject
$ git config --add hooks.cia-use-rpc 1 # Only if you want to submit with XML RPC instead of mail
$ git config --add hooks.cia-rpc-uri http://cia.vc/RPC2 # Only to use another CIA server

Using personal Git repositories

Creating personal Git repositories

It is also possible to have personal Git repositories. Just log in on alioth, then

$ mkdir ~/public_git
$ chmod a+xr public_git  # give access to git daemon
$ exit

Consider $PRJ is your project name, $PRJDIR the path to your local repo of the project and ALIOTHUN is your alioth user name.

export PRJ=proj                                # the name exported project (e.g.'pbuilder')
export PRJDIR=~/proj                           # path to your current local git repo
export login=youraliothusername                # duh, your alioth user name

Log out to prepare the repository that will be published. Copy over to alioth.

git clone --bare $PRJDIR $PRJ.git              # create the exportable directory
touch $PRJ.git/git-daemon-export-ok            # tell git daemon that it is a public repo
chmod a+x $PRJ.git/hooks/post-update           # fetches over http work
(cd $PRJ.git && git-update-server-info)        # fetches over http work
scp -r $PRJ.git/ $login@alioth.debian.org:public_git/ # copy the repo to alioth

Check that your repo is visible by using a browser to access your new repo:

http://git.debian.org/?p=users/$login/$PRJ.git;a=summary

Check that it works in some empty temp dir:

git clone git://git.debian.org/~$login/$PRJ.git
# alternatively, you could use the (slower) http fetch method
#git clone http://git.debian.org/git/users/$login/$PRJ.git

Note: Using a sshfs mount to create the bare repository results in some errors and, apparently, is slower than creating the repo on the local disc, and then scp-ing it to alioth.

The symlinks used for the gitweb interface are updated every six hours.

They will be available through the following URLs:

$ git clone git://git.debian.org/~$login/$PRJ.git

Maintaining the published Git repository up to date

Pushing to that repo is done with:

$ git push ssh://$login@alioth.debian.org/~$login/public_git/$PRJ.git


?CategoryAlioth