This doesn’t happen specifically in the commit, but when you push or pull.
The reason is that you have a different version of the repository, and someone made changes to the code in the same part as you.
When you try to synchronize (push/pull) the remote repository, to effect the changes git performs what we call the merge (merge) of the code. Usually this occurs without problems, when there are no conflicts.
A conflict occurs when there are two commits that usually change the same part of a code, and with that, git cannot automatically resolve, so it places some conflict markers (Conflict markers) to signal where the conflict occurred.
Example:
<<<<<<< HEAD
foo
=======
bar
>>>>>>> cb1abc6bd98cfc84317f8aa95a7662815417802d
Source
The part where it says <<<<<<< HEAD
means that this is the part of your local code, which is in your branch where the merge was done.
The part where it says ====
and >>>>>>> cb1abc6bd...
means the start and end of the commit from which you pulled, and this is where the conflict occurred.
What you must do?
Correctly analyze the party that gave conflict, because since two people made changes to the same part of the code, the most recommended is that it be aligned with the person responsible for the commit which was actually made, and what can be done to integrate your part of the code with that of the responsible person, so that both do not miss the job done.
At the end, remove the conflict marks
and commit another commit, identified as merge
.
For more on the subject, I recommend reading the official git documentation (in English):
Merge
It’s a merge problem.
– viana
these are conflicts that you need to resolve before climbing, you may notice that just below this mark will have an old code chunk that Voce modified or identico, that the change is not in this specific stretch
– Gabriel Oliveira