Changing the hooks
If you are able to change the hooks, you can just add a toggle for each
one. Or just use a script to temporarily rename a given hook,
as commented.
Either way will selectively skip the problematic hook while letting the
other ones run normally. This ensures that other checks occur (if they exist),
such as a commit message validation with the commit-msg
hook.
Committing
If that does not apply, there is an alternative:
Usually, when an operation is stopped by a conflict, after fixing it you can
just run
git commit
instead of
git $operation --continue
This applies to revert
, merge
, cherry-pick
and possibly others (although
in rebase
it might behave differently, since it is a sequence of operations).
So, as noted, to bypass the hooks, you can just add --no-verify
:
git commit --no-verify
Note: The feature above seems to be undocumented, but it WorksForMe(tm).
From a diff of strace git commit
and strace git revert --continue
, the
former does a lot of other things (515 vs 173 lines, respectively), such as
checking if a rebase is in progress and creating some temporary files in
$GIT_DIR/objects
. Example:
stat(".git/MERGE_HEAD", 0x7ffefb5d0760) = -1 ENOENT (No such file or directory)
stat(".git/rebase-apply", 0x7ffefb5d0620) = -1 ENOENT (No such file or directory)
stat(".git/rebase-merge", 0x7ffefb5d0620) = -1 ENOENT (No such file or directory)
stat(".git/CHERRY_PICK_HEAD", 0x7ffefb5d0760) = -1 ENOENT (No such file or directory)
stat(".git/BISECT_LOG", 0x7ffefb5d0620) = -1 ENOENT (No such file or directory)
stat(".git/REVERT_HEAD", {st_mode=S_IFREG|0644, st_size=41, ...}) = 0
lstat(".git/REVERT_HEAD", {st_mode=S_IFREG|0644, st_size=41, ...}) = 0
openat(AT_FDCWD, ".git/REVERT_HEAD", O_RDONLY) = 4
But the result appears to be same: They open up the editor with the
git-generated message (e.g.: "This reverts commit [...]") and commit after
exiting. I have used the alternative form multiple times and never had any
problems at least (by the way, I probably discovered it under the same
scenario).
hooks.sh
that takes one argument:enable
ordisable
. When feedingdisable
, I take my pre-commit hook and rename it topre-commit.disabled
. Once done, I call./hooks.sh enable
which renames the file back topre-commit
– Endotoxingit git config core.hooksPath ""
and then after you're done with therevert --continue
, turn it back on withgit config core.hooksPath hooks/
(assuming your hooks path is/hooks
). This won't work if you just want to turn off the precommit hook (and want your postcommit hook to still run, for example). – Higginson