Project

General

Profile

Git

Here are some tips that may help you in managing your repository in Redmine. These are particularly helpful if you push and pull from many places.

There is a good introductory video by Randal Schwartz.

Email notification on pushes

Chris Green and Marc Mengel have packaged up the git-comit-notify ruby scripts on cdcvs for use in Git repositories.
To set it up:

  • add a config/mailinglist.cfg to your repository, with
    a comma separated list of email addresses [Note that as of the recent email service changes,
    it must be "" and not just "user"]. This file has to exist on the "master" branch.
  • login to your p-project account
  • cd /cvs/projects/project/hooks
  • ln -s /local/ups/db/fnal_git_notifier/current/bin/post-receive .

and you should be in business.

There is now an alternate script, which uses a mailinglist config from your Redmine project settings.

proj=my_project
cd /cvs/projects/$proj/hooks
ln -s /fnal/ups/db/fnal_git_notifier/current/scripts/fnal-git-notify-redmine post-receive

and put in your projects/Settings in the mailinglist box

mailinglist: user1@fnal.gov,user2@fnal.gov,...

Add a Redmine remote

To save you the keystrokes of having to type the full ssh url every time you push or pull from your repository, you can add a remote. For the following example, I'll call the new remote redmine

git remote add redmine ssh:///cvs/projects/project

Now, I can push and pull from my redmine repository by just specifying the remote name


 [user@localhost project]$ git push redmine master
 Counting objects: 7054, done.
 Delta compression using up to 4 threads.
 Compressing objects: 100% (6166/6166), done.
 Writing objects: 100% (7054/7054), 5.59 MiB | 2183 KiB/s, done.
 Total 7054 (delta 4739), reused 899 (delta 668)
 To ssh://p-project@cdcvs.fnal.gov/cvs/projects/project
 * [new branch]      master -> master
 [user@localhost project]$

Setting up a mirror with GitHub

If you want to mirror a repository on GitHub, for project myproject:

  1. make an ssh key for (ssh in as and use ssh-keygen)
  2. setup a repository on github, and allow that ssh key in.
    http://help.github.com/deploy-keys/#how_do_i_add_my_deploy_key
  3. add a git remote: ssh in as and do:
     git --git-dir=/cvs/projects/myproject remote add --mirror github github-url 
  4. add a
     git push --quiet github & 

    to the /cvs/projects/myproject/hooks/post-receive hook file.
    That's the outgoing side of the mirror (cdcvs->github)
  5. To make it bidirectional, you could add a crontab entry:
      */30 * * * * git --git-dir=/cvs/projects/myproject fetch --quiet github 

    That's the incoming side of the mirror (github->cdcvs)
    But do NOT do that. We are currently evaluating the security implications of
    allowing GitHub to athenticate pushes which then automatically propogate to
    Fermilab.

Getting tarballs of releases

If you're using Git, and your package is "public" you can

wget http://cdcvs.fnal.gov/cgi-bin/git_archive.cgi/cvs/projects/$p.$v.tgz

to get version $v of package $p as a gzipped tarfile. $v must exist as a tag in the
repository.

Supported archive/compression suffixes are:

  • tar (tar, no compression)
  • tgz (tar, gzip)
  • tbz2 (tar, bzip2)
  • zip (zip archive, compression)