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.
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.
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 .
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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With