-2

I am working with git and in my code I see that these <<<<HEAD and >>>>develop comments are added to my code by git. Like this:

<<<<<<< HEAD
        <b>code</b>
=======
        <b>more code</b>
>>>>>>> develop

What should do with these lines of code? Can I just remove them?

bakkal
  • 54,350
  • 12
  • 131
  • 107
Rbijker.com
  • 2,894
  • 3
  • 21
  • 26

6 Answers6

8

What are they?

Those are conflict-markers, they begin with <<<<<<< and end with >>>>>>>

Why did it happen?

They can happen when you get conflicts while merging. E.g. merging two commits that change the same line (Git can't decide for you which version to follow)

What can I do?

You can resolve the conflict by editing manually, removing the marks, and then committing.

For you, as you can see you have a conflict between HEAD and develop, as the person doing the merge, you can freely choose which version to follow, or manually mix and match by editing.

Where can I learn more about this?

There's several ways to approach this I suggest you search for a mix of these keywords on StackOverflow and the web: "Git merge conflict resolution".

Community
  • 1
  • 1
bakkal
  • 54,350
  • 12
  • 131
  • 107
1

Those indicate that there is conflict in your code. This means that a teammate code conflicts with yours and you need to manually decide whose code to keep.

Note: sometime you might see that there is no code difference between yours and your teammates but git still shows a conflict. This is due to space or tabs conflict.

Rana
  • 1,675
  • 3
  • 25
  • 51
1

This is the outcome of a conflict.
You can read all about it here:
What is the diff version git use? diff2 or diff3?

Here is what each signs(s) mean and where they are coming from.

enter image description here

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
0

This occurs when Git cannot automatically do a merge. This text is there to let you know where Git could not merge automatically.

You can use the command git mergetool to help you to find and deal with all these occurrences.

0

This occurs when you have a conflict in your code. Basically, you need to choose between the head or the develop branch version of your code. The conflicts occur in git when you touch a piece of code and in other branch the same line(s) is/are modified. So when merging/rebasing you need to choose what to keep:

To choose, just pick the line of code you want and erase the other line and the indicators:

I.e, if i want to preserve code, that's the only thing to left.

If you don't want to solve conflicts, use a tool like diffmerge.

0

You encountered a conflict.

This happens when multiple commits change the same code in different ways.

You have to resolve the conflict by editing and then commit or git add files and git rebase --continue, depending on operation you tried to do when conflict occurred.

See git manual on this - here

Vasfed
  • 18,013
  • 10
  • 47
  • 53