The to-do list command `reword` replays a commit like `pick` but lets
the user also edit the commit's log message. This happens in two
steps. Firstly, the named commit is cherry-picked. Secondly, the
commit created in the first step is amended using an unchanged index
to edit the log message. The pre-commit hook is meant to verify the
changes introduced by a commit (for instance, catching inserted
trailing white space). Since the committed tree is not changed
between the two steps, do not execute the pre-commit hook in the
second step.

Specify the git-commit option `--no-verify` to disable the pre-commit
hook when editing the log message. Because `--no-verify` also skips
the commit-msg hook, execute the hook from within
git-rebase--interactive after the commit is created. Fortunately, the
commit message is still available in `$GIT_DIR/COMMIT_EDITMSG` after
git-commit terminates. Caveat: In case the commit-msg hook finds the
new log message ill-formatted, the user is only notified of the
failed commit-msg hook but the log message is used for the commit
anyway. git-commit ought to offer more fine-grained control over
which hooks are executed.

Signed-off-by: Fabian Ruch <>
--- | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/ b/
index 689400e..b50770d 100644
--- a/
+++ b/
@@ -504,10 +504,19 @@ do_next () {
                do_pick $sha1 "$rest"
-               git commit --allow-empty --amend --no-post-rewrite 
${gpg_sign_opt:+"$gpg_sign_opt"} || {
-                       warn "Could not amend commit after successfully picking 
$sha1... $rest"
-                       exit_with_patch $sha1 1
-               }
+               # TODO: Work around the fact that git-commit lets us
+               # disable either both the pre-commit and the commit-msg
+               # hook or none. Disable the pre-commit hook because the
+               # tree is left unchanged but run the commit-msg hook
+               # from here because the log message is altered.
+               git commit --allow-empty --amend --no-post-rewrite -n 
${gpg_sign_opt:+"$gpg_sign_opt"} &&
+                       if test -x "$GIT_DIR"/hooks/commit-msg
+                       then
+                               "$GIT_DIR"/hooks/commit-msg 
+                       fi || {
+                               warn "Could not amend commit after successfully 
picking $sha1... $rest"
+                               exit_with_patch $sha1 1
+                       }
                record_in_rewritten $sha1

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to