Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git hook for merge conflicts

Tags:

git

githooks

hook

Is there a git hook I can use for merge conflicts? After a failed git merge, it would be great to be able to write a script that opens all files with conflicts in $EDITOR. Unfortunately the post-merge hook doesn't run if there are conflicts and from what I've seen in the githooks man page, there are no other applicable hooks.

I'm wondering if I've missed something, or if there are other alternatives short of aliasing 'git merge' to a function or something like that.

Thanks, Chris

like image 444
flooose Avatar asked Mar 10 '12 18:03

flooose


1 Answers

As suggested by Charles Bailey, the best way to do this is by customizing the mergetool. Using this guide, I came up with this simple way to have merge conflicts opened in my editor:

[merge]
  tool = emacs
[mergetool "emacs"]
  cmd = $editor \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"

Since Charles Bailey never answered how I should give him credit for this, I hope this is an appropriate way to finally close this question.

like image 153
flooose Avatar answered Sep 22 '22 06:09

flooose