Why is it that when I do "commit," my project is full of errors?

Asked

Viewed 70 times

0

I recently started working with Github to commit my projects but every now and then I notice something very annoying: my project gets FULL of errors, what I see most is:

<<<<<<<<<"HEAD ===========" <<<575439787438

Why did this happen? There’s no way around it?

  • It’s a merge problem.

  • 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

1 answer

0


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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.