Bypass post-commit hook temporarily
I have a testing script, which needs to commit changes before running tests and then it reverts that commit back. So, I don't want this fake commit to call post-commit hook, which may do something that won't be restored by reverting commit.
There is an option for bypassing pre-commit hook: git commit --no-verify ...
, but I haven't found anything similar for post-commit. Here is a piece of my script, with simple solution for the problem:
gitdir="$(git rev-parse --git-dir)"
hook="$gitdir/hooks/post-commit"
# disable post-commit hook temporarily
[ -x $hook ] && chmod -x $hook
git commit -a -m "Commit all changes for testing. Will be reverted automatically"
# enable it again
chmod +x $hook
We just make the hook not executable for this commit and that's it!
Idea is taken from here
Written by Alexey Alekhin
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Hooks
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#