I would write a wrapper for your system, perhaps "commit.php" or "git -ci.sh" or something else. Then you can use bash or perl or python or php, or whatever is convenient for you, and run each command one by one, ending with a commit.
I suggest this after you encounter similar problems, trying to add to the commit that the pre-commit hook is running. In addition, there is no โpushโ or โpullโ hook on the downstream side (I use a central repository so that this can work if you have two machines that push and pull with each other, as you think).
I have a two way deployment script for one of my websites where I have a long pre-commit script, but on a web server I have a wrapper like this one that retrieves, then checks the commit, gives a report and gives me options about merging and rsync with another server, etc. He replaced the โpullโ hook, which would probably be a serious security risk.
Hans
source share