I need to perform some actions (prepare gettext *.mo message files) on my project everytime I run git pull
. Is there any suitable git hook, which I could use for this purpose please?
The githooks
man page is a complete list of hooks. If it's not on there, it doesn't exist.
That said, there is a post-merge hook, and all pulls include a merge, though not all merges are pulls. It's run after merges, and can't affect the outcome. It never gets executed if there were conflicts; you'd have to pick that up with the post-commit hook if it really matters, or invoke it manually.
@Jefromi "all pulls include a merge" , even if I do a pull --rebase ?
Also found that merge never executes when running
git pull
if there are no changes to be pulled in (you are already up-to-date).@jbergantine: I suppose I was imprecise in my answer - all pulls that aren't no-ops include a merge. But... in general, if you're trying to take action whenever a merge happens, I don't think you want to take action when someone does a no-op merge. For example, it'd be a waste for the OP to recreate those files if nothing has changed.
If you really want to do something every time you pull... you could alias 'git pull' so that you call a script that does the git pull then does something else
git pull
with rebase (either with--rebase
or with the configpull.rebase=true
) doesn't include a merge and won't trigger the post-merge hook. For this case you can specify--no-rebase
to make sure the hook is triggered or make use of the post-rewrite hook.