TxH TxH - 3 months ago 14
Git Question

Git post-rewrite not executed

I have an executable

.git/hooks/post-rewrite
file, which for testing purposes
has the following lines in it:

#!/bin/bash

echo "Notice: post-rewrite hook is running"


My understanding is that the
post-rewrite
hook runs after operations that rewrite commit history, such as
rebase
and
git commit --amend
.

Indeed, running
git commit --ammend
will print the message to
stdout
after commiting. However, when I do
git rebase master
from a branch that is behind
master
, or
git pull --rebase
, nothing is printed to
stdout
.

Am I missing something?

Answer

when I do git rebase master for a branch that is behind master; or git pull --rebase

You are not rewriting any commits; you are fast-forwarding; so basically your branch just points to another commit. None of the commits are rewritten.

Comments