Reputation: 29579
I'm not sure what the correct way of addressing this scenario is in git, whatever I do I get weird results.
I have a version X of a file, in commitish A. Over time, this file has been modified and is now at commitish A'.
Someone emails me a file X' which is a modified version of the file that was contained in commitsh A. Important: this change is out-of-band (via email and not git) and out-of-date (changes to an earlier version of the file).
I know exactly what I "want" to do in git terminology, but I'm not sure as to the cleanest way of pulling it off: rewind, commit, replay. I assume it's supposed to be that simple, and I know git does this internally when it rebases, but I can't get it to work myself.
What I've done:
My problem is that the merge of branch B with master results in a conflict for all the lines in the file.
The changes in the files (I think this is why) are as follows:
Version A:
line 1
line 2
line 3
branch master:
line 1, file 1
line 2, file 1
line 3, file 1
emailed file:
line 1
line B
line 3
As you can see, branch master includes changes to all the lines, but the lines remain intact. Out-of-band changes is a modification to line 2.
Merging tells me that ALL the lines in the document are conflicted. I can understand if git simply cannot merge the changes from line 2 across the two revisions, but I do not understand why all 3 lines are being marked as conflicted.
Can someone please help me out?
Upvotes: 2
Views: 173
Reputation: 29579
I'm not sure if this is the "correct" solution, but barring another workaround, I'll be accepting this:
By configuring git to use an external diff/merge editor, in this case the amazing and all-powerful BeyondCompare3, I was able to work around this. BC3 has much finer "blocks" of changes, detecting modifications in the same line. While I still had to manually merge the changes, it only marked the individually-altered lines as changed (though it did show that Git had already detected a much-larger surrounding block as modified, it gave me the option of overriding it).
Upvotes: 1
Reputation: 5266
Correct me if I'm wrong, but it looks like you actually want to run git rebase B
as your last step, not git merge B
.
However, you may still have a merge conflict for all three lines because the lines are so close to each other that git doesn't want to assume that the conflict is only in line 2 not lines 1-3.
Upvotes: 0
Reputation: 993971
I think you answered your own question.
As you can see, branch master includes changes to all the lines
When merging, Git does not know which set of changes is more important to you. You must make this choice yourself.
Upvotes: 1