1

-Initial File Content:

1
2
3

-File Content at Branch A):

1 changed line by A
2
3

-File Content at Branch B):

1
2 changed line by B
3

-File Content i want to achieve at Branch B after merging A into B:

1 changed line by A
2 changed line by B
3

Which merge strategy enables me to achieve this result automatically?

Normal (recursive) merge results in this, and its not solvable automatically:

0 
<<<<<<< HEAD
1 changed line by A
2 
=======
1 
2 changed line by B
>>>>>>> refs/remotes/Remote-B/master
3 
CodeHunter
  • 11
  • 4

1 Answers1

1

Given the volume of merging done by some projects using git, I think it's safe to assume anything it doesn't do automatically produces bad results too often to tolerate.

Those are in the same change hunk, too close together for git's automerge's taste.

jthill
  • 55,082
  • 5
  • 77
  • 137
  • indeed, just before i have read your post, i tried to make the changes on line 1 and line 3 instead of 1 and 2, so git could separately automerge, and it worked – CodeHunter Nov 28 '15 at 23:22
  • is there a way to make with work the way i want it, with line close to each other like in my example? – CodeHunter Nov 28 '15 at 23:30
  • Replace one line with the corresponding line from another buffer is editor macro territory. You can get git to invoke your custom merge, it's easy to write one that postprocesses the merge-file output, but that seems like heavyduty overkill here. – jthill Nov 29 '15 at 02:36