I\'ve got a post receive hook setup on the remote repo that tries to determine the branch name of the incoming push as follows:
$branch = `git rev-parse --abbrev
You could also do something like this using bash variable substitution:
read oldrev newrev ref branchname=${ref#refs/heads/} git checkout ${branchname}