1

Consider this example command line session...

$ git --version
git version 2.19.0.windows.1    
$ echo "header" > ancestor.txt
$ cp ancestor.txt left.txt
$ cp ancestor.txt right.txt

At this point, I've made an ancestor file and started two "branches". Now I'll make a change to each one.

$ echo "on the left" >> left.txt
$ echo "on the right" >> right.txt

And another, with coincidentally identical lines.

$ echo "footer" >> left.txt
$ echo "footer" >> right.txt

Now I want to merge my two branches together using git merge-file.

$ git merge-file --union left.txt ancestor.txt right.txt
$ cat left.txt
header
on the left
on the right
footer

There is only one "footer" line in the merge output. My expectation is that because each branch file has footer separately and the ancestor doesn't, I should get two "footer" lines in the merge, one from the left and one from the right. (I am only expecting one "header", because it is in the ancestor.)

If I repeat the experiment up to the git call, but replacing ancestor.txt with an empty file, I get exactly the same output. Even if I fill ancestor.txt with junk, I still get the same output.

Am I doing this wrong? Have I found a bug in git? Is the ancestor file redundant? What's going on?

  • Dear voters-to-close, is there a better SE site for this type of question please? – billpg Feb 20 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.