I have looked and found all sorts of git hook guides, but none seem to fit this specific, simple scenario.
I have my own server that I push code changes to (with git push origin master). After I do this, I have to ssh into the server and run a function that I have setup, "update-code", that clones the repo, runs ant, & restarts tomcat, etc. I want git to run this 'update-code' command for me after any user has run 'git push' (from their machine, not the server).
To recap, after any user pushes to my repo (from their machine), a shell command is automatically executed on the server the same way it would be if I were logged in and typed 'update-code'. What are the exact steps to have git do this?
You want to use a
post-receivehook (seeman githooksfor details):Note that if multiple references are updated in the same push, this is only called once. If you need to be called and take action on different references (i.e. do one thing for
masterand another thing forrelease/) then you should look at thepost-updatehook instead.These would be stored on your remote server, in the
foo.git/hooks/directory. Make sure that these scripts are executable.