7

I have a wordlist file in git that I update from multiple machines and merge as needed. When I merge I usually get conflicts that are easy to resolve algorithmically: since it should stay sorted alphabetically, just accept all additions and deletions from both sides of the merge and sort the result.

For example:

APIs
<<<<<<< HEAD
arg
=======
apps
>>>>>>> master
attr

should be resolved to:

APIs
apps
arg
attr

Is there any way I can automate this process away so git always does the right thing for this file and never reports conflicts?

Mu Mind
  • 10,935
  • 4
  • 38
  • 69
  • 5
    you will need to define a new merge _strategy_ in `~/.gitconfig`, and then in the `.gitattributes` file of repo specify that strategy for the given path; see [here](http://stackoverflow.com/questions/23140240/git-how-do-i-add-a-custom-merge-strategy) and [here](http://nuclearsquid.com/writings/git-tricks-tips-workflows/#gitattributes-5:458b907a1ab49e897adb85ef97309813). – behzad.nouri Apr 18 '15 at 19:26

1 Answers1

0

Use git hooks to "catch" the commit or any other required phase and run your own script to fix it the way you need.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167