I\'m writing a pre-receive hook to do some validation before accepting commits on the push. It works fine with existing branches since I use following git command to get a list
The following helped in my case. I personally think it's very simple.
OLD_REV=$2 NEW_REV=$3 if [ $OLD_REV == "0000000000000000000000000000000000000000" ]; then OLD_REV=$(git merge-base master $NEW_REV) fi; git diff --name-only $OLD_REV $NEW_REV