Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Merge Conflict Custom Auto-Resolution

Is there any way to write a custom merge conflict resolver in git? We are having evil merge conflicts resulting from changing java import statements on multiple branches. These seem like they would be fairly easy to write a plugin to handle automatically 90% of the time. Does git have hooks that would allow us to write custom auto-merge behavior for just this situation?

like image 540
xdhmoore Avatar asked Nov 01 '22 19:11

xdhmoore


1 Answers

You can define a new merge strategy in .gitconfig as described here.

[merge "mymergescheme"]
        name = my awesome merger
        driver = "my_executable_here"

You can then specify that merge strategy for particular files inside .gitattributes as described at the same page.

src/*.java merge=mymergescheme
like image 64
merlin2011 Avatar answered Nov 15 '22 03:11

merlin2011