Question

In a conflict resolution file generated by git, only common code should be displayed outside the markers ('<<<<<<< ours' - '>>>>>>> theirs') - correct?!

I have a CSS file with comments that I have inserted in the local version and a conflict occurred, and this comment segment is listed outside the markers.

This occurs both in normal style and in diff3 style (base segments included).

When using a visual tool (p4merge in my case), The said text segment is shown only in local, but not in base or remote.

Also checked:

git checkout --theirs <file-name>
--> said segment not there

git checkout --ours <file-name>
--> said segment there

git checkout -m <file-name>
--> said segment outside markers

So what's going on?!

Was it helpful?

Solution

How "close" is the "local-only" change to the part of the file that has a conflict?

It is possible that there was no textual conflict near the part of the file where your "local only" change was, and that part of the file was merged automatically.

For example, say you start out on branch A with a file named README that looks like this:

README

foo

bar

Then you fork a new branch B. On branch B, you change README to look like

README

foo

baz

and commit it. Now you switch back to branch A, and you make two changes and commit, so branch A's README looks like:

README

frotz

foo

qux

Now you merge B into A. This is what you get (using the diff3 conflict style):

README

frotz

foo

<<<<<<< HEAD
qux
||||||| merged common ancestors
bar
=======
baz
>>>>>>> B

As you can see, git auto-merged the first part of the file, but punted on the second part.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top