Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing a git-hook after pull --rebase

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.

like image 531
TxH Avatar asked Aug 25 '16 14:08

TxH


People also ask

Should I git pull after rebase?

There is no need to do a git pull after you have rebased your feature branch on top of master . With your current workflow, the reason why git status is telling you this: Your branch and 'origin/feature' have diverged, and have 27 and 2 different commits each, respectively.

Is git pull rebase same as git pull?

This two git commands are not interchangeable. Git pull downloads the newest changes from the remote repository and applies the changes to your local repository. Generally, git pull is git fetch and git merge. Rebasing on the other hand can be a replacement for git merge .

How do you trigger a pre-commit hook?

If you want to manually run all pre-commit hooks on a repository, run pre-commit run --all-files . To run individual hooks use pre-commit run <hook_id> . The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow.


1 Answers

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:

like image 169
larsks Avatar answered Oct 13 '22 11:10

larsks