This question already has an answer here:
I'm executing a programme to alert CruiseControl each time an update is sent to our remote repository. I'm using a Git post-update hook for this.
It would be great if I could find out which branch had been committed so I could use that to inform CruiseControl which branch to build. Is there any way to access the branch name within a post-update hook?
The first parameter to the post-update hook is the branch reference in full - for instance I see 'refs/heads/master' for a push to 'origin master'. So an example hook script that just prints the branch modified is:
To illustrate, when the above is placed into your remote repository hooks/post-update file the following is printed when performing a push:
The new line beginning 'remote:' was output by our hook script.