Git: extract branch name in post update hook
But if branch was deleted (for example by git push origin :branch-name), you will receive errors from this command, so I think it’s safer to use another method:
As post-update hook receives branch’s path as first parameter (something like refs/heads/branch-name), you can extract the branch name using awk, and then check if branch exists in refs/heads folder, again using first parameter.