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
Magnus' solution didnt work for me, but this did:
#!/bin/bash
echo "determining branch"
if ! [ -t 0 ]; then
read -a ref
fi
IFS='/' read -ra REF <<< "${ref[2]}"
branch="${REF[2]}"
if [ "master" == "$branch" ]; then
echo 'master was pushed'
fi
if [ "staging" == "$branch" ]; then
echo 'staging was pushed'
fi
echo "done"