Another OS X git UI: SourceTree

Besides gitx, I now was shown another git user interface for OS X. It is called SourceTree:

It is more mature and feature-rich, compared to gitx. But it is closed source. However, it is free (as in beer) for the time being in the App Store. So far, the program seems really nice. Let’s see how long I will continue using it, and if I’ll go back to gitx at some point.

Switching the active branch in a bare git repository

If you ever need to delete the “active” branch in a git repository, you need to first switch the active branch. Because you cannot delete the branch you are sitting on… You cannot checkout a branch, as you would usually do. You have to change the symbolic reference called HEAD. You can do this with the symbolic-ref command:

$ git branch
* deletethis
somebranch
$ git symbolic-ref HEAD refs/heads/somebranch
$ git branch
deletethis
* somebranch
$ git branch -d deletethis

Setting the sender of git post-receive hooks

There is a nice stackoverflow posting about how to set the sender of git post-receive hooks. I used this, slightly augmented:

#!/bin/sh

# Use the name and email address of the author of the last commit.
USER_EMAIL=$(git log -1 --format=format:%ae HEAD)
USER_NAME=$(git log -1 --format=format:%an HEAD)
. $(dirname $0)/post-receive-email

I then also changed the default post-receive-email script, to look like this in the send_mail() function:

send_mail()
{
if [ -n "$envelopesender" ]; then
/usr/sbin/sendmail -t -f "$envelopesender"
else
/usr/sbin/sendmail -t -F "$USER_NAME" -f "$USER_EMAIL"
fi
}
This will let the emails come from the last user in the git log. This is only a hack, and might break or not make sense under certain circumstances, but is good enough for most of my needs.

gitx with push / pull support

I love gitx, the git GUI for OS X. However, it used to have no push / pull support. Which is pretty important for git. But git and github are beautiful pieces of software. So there is another fork on github, containing push / pull support and more. This little context menu made me happy:

Readymade binaries can usually be found on Brotherbard’s blog.
Update: There is a better, newer branch even yet. See my other blog post.

How to set up git email notifications

This is not very well documented in the git user manual. Here is what I did:

Go to your central repository, not your working copy. There, change to the hooks directory:

cd /path/to/yourproject/hooks
cp post-receive.sample post-receive

If your repo is not a bare repository, you have to change to .git/hooks to do this. The post-receive-email script can be found under contrib/hooks/ in the git documentation (e.g. in /usr/share/doc/git/contrib/hooks on most Linux distributions).
Now configure the email hook:

git config hooks.mailinglist “email1@bla.com, email2@bla.com”
git config hooks.envelopesender yourname@informatik.rwth-aachen.de
git config hooks.emailprefix “New commit: “

Also you should give your project a name:

$EDITOR /path/to/yourproject/description