This answer works nicely with bypassing the precommit hooks, but the best way to skip the pre-commit seems to disable it with something like this:
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
Took from here.
The question is - is there a way to do it better?
The reason for my doubts is that disabling the hook by removing execution rights seem a non-natural way of preventing something to run. After checking the web I found a natural way of skipping pre-commit
case - we can just provide an option for git to skip the check. Basically, my question is if we have anything similar, or more or less accepted way of doing the thing.