Following an answer to a previous question, I implemented a Git hook script which needs to fire whenever the working directory is updated. I linked this script to the following in .git/hooks:
- post-checkout
- post-commit
- post-merge
This mostly works, but not always. One case I found is git stash
. This is a problem because my hook generates a text file wihch I also mark with git update-index --assume-unchanged
to tell Git that I don't want to check in changes (an empty version is checked in). However, git stash
will revert the assume-unchanged file (to the empty file), which means the hook needs to run again, yet the hook is not invoked after git stash
.
I suspect a similar problem may exist with git rebase
too, but that's not as easy to explain.
I want a hook which Git will always run after updating the working directory. Is this possible?