I am following an example from a book which does not show the step to resolve a merge conflict. The tutorial which teaches that did not work for me as mentioned in this post
Those are merge markers:
<<<<<<<
Changes made on the branch that is being merged into. In most cases,
this is the branch that I have currently checked out (i.e. HEAD).
|||||||
The common ancestor version.
=======
Changes made on the branch that is being merged in. This is often a
feature/topic branch.
>>>>>>>
As explained in "Fix merge conflicts in Git?", you are supposed to:
Or you can simply checkout those file to keep the original version, as in "How can I discard remote changes and mark a file as “resolved”?".
As you can see, the name you have deleted from the Finance Team
in marketing
branch (Stacy
and Alexander
) are back.
So when you are merging master
into marketing
, git is asking you: decide, should we keep those names or removes them?
As Charles Bailey adds in the comments, it seems the (base) common ancestor section is missing:
|||||||
The common ancestor version.
=======
you should redo the exercice with the config:
git config merge.conflictStyle diff3
That will help visualize the base section of the 3-way merging.
See also "Why is a 3-way merge advantageous over a 2-way merge?".
The OP adds
After you decide what to keep in the text file and remove the merge markers,
<< and
>>>master
, you need to add the files to the stage withgit add [filename]
, then commit as normal.
You cannot just executegit merge master
right away.
When merging again, the OP reports the error message:
error: 'merge' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm ' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: Exiting because of an unresolved conflict.
Here is the solution
git add .
git commit - m "success"
git merge master
See "GIT merge error “commit is not possible because you have unmerged files”".