I’m experimenting with git-hooks and custom repo layout, where I need to prepare (update in a special way) sources before pulling changes from the remote.
I couldn’t find the proper git-hook in the official list, and few related questions (like Is there any git hook for pull?) aren’t applicable in my case, since they usually focus on the post-pull phase (i.e. can be handled with post-merge
or a simlar hook), while post-fetch is the last phase when I can do my tricks with the sources 🙂
In short
The hook (script) should run evey time I pull, but before git applies the remote changes locally.
If the script fails (returns non-zero exit code) the pull should be rejected/canceled.
There are no git-hooks like pre-pull
or post-fetch
.
So far I see only two workarounds:
- run extra script manually and then run
git pull
(both steps can be combined in one script) - add a git-alias to be invoked instead of
pull
Some of the team-mates (including me) use TortoiseGit frequently, and mentioned workarounds won’t align properly with this tool.
Git version: 2.41
OS: Windows 10
See also:
- How would I write a pre-merge hook in Git?