I have a remote server on which I have created a bare git repository.
I would like to create a hook so that a given script is run on the latest code received on any given branch.
I know the post-receive hook can be used for it. However I want to do the following:
- Get hold of the branch on which code was received.
- Checkout the code in a temp location and run an operation on it.
How do I do the above?
“Not able to detect branch from Git post-receive hook“
“Managing website using git + post-receive hook: error pushing changes“
See both techniques combined in “Git post-receive for multiple remote branches and work-trees“: