Executing a git-hook after pull --rebase

2019-04-30 15:18发布

问题:

I'd like to have a hook run after doing git pull --rebase in order to check if a certain file was changed. Something along the lines of this hook.

I initially thought of using the post-rewrite hook, however that only works when commits are being rewritten, and won't run when the pull operation simply fast-forwards the branch, which is very often.

Any ideas will be appreciated.

回答1:

I ran strace git pull --rebase on a local repository, which performed a fast-forward update...

First, rewinding head to replay your work on top of it...
Fast-forwarded master to b0a60c3302973ca1878d149d61f2f612c8f27fac.

...and it looks as if git calls the post-checkout hook in this case: