What is a merge conflict in Git and how to resolve it without losing changes?

Published on 2026-10-20 by frfrand

Cómo aparecen los conflictos de Git, qué significan los marcadores de conflicto y cómo resolverlos con pruebas y sin descartar trabajo.

What is a merge conflict in Git and how to resolve it without losing changes?

A merge conflict occurs when Git cannot automatically decide how to combine certain changes from two lines of development. It does not mean that files have been lost or that someone programmed incorrectly: it means that a human decision is needed.

It is common when two people modify the same lines of a file, or when one branch deletes something that another modified.

Two people editing the same sign

Imagine there is a sign that says «We open at 9». One person changes it to «We open at 8» and another writes «We open at 10». There is no correct answer that a machine can infer without knowing the intention.

That is similar to a Git conflict. It can combine many changes without help, but there are situations where showing you the alternatives is safer than inventing a mix.

What does a conflict look like?

A file can end up with marks like these:

<<<<<<< HEAD
horario = "08:00"
=======
horario = "10:00"
>>>>>>> feature/horarios

The first part represents one version and the second another. Those lines should not remain in the final code. Your job is to decide which behavior should be kept, or write a third solution that combines the intentions.

The names and tags may vary depending on the operation and tool.

An orderly way to resolve it

  1. Run git status to identify which files need attention.
  2. Open each conflict and understand what each branch was trying to do.
  3. Edit the file until you get a correct result, removing the markers.
  4. Run tests or at least the relevant check.
  5. Use git add file to indicate that you resolved that conflict.
  6. Complete the merge operation with the procedure indicated by Git.

It is not enough to make the text compile: both changes may have incompatible business rules. If one branch added a discount and another modified taxes, combining them without looking can produce incorrect numbers.

Can I automatically keep one version?

There are options that favor one side or the other of the conflict. They can be useful in specific situations, but using them indiscriminately is equivalent to throwing away the work of one branch.

The difference between resolving a conflict and hiding it is understanding the result.

And if I want to cancel?

While you are in an ongoing merge operation, git merge --abort can attempt to restore the previous state. Even so, it is advisable to avoid starting complex operations with unsaved local changes, because it is not always possible to recover any state automatically.

Before merging important changes, make a coherent commit or temporarily save your work deliberately.

How to reduce conflicts in a team

Integrate changes frequently, keep tasks separate when reasonable, and avoid having several people continuously editing the same huge file. Pull requests help discuss expected behavior before integrating.

A conflict is not automatically anyone's fault. Sometimes it simply indicates that work progressed in parallel.

How is this reflected in ArduMaker?

If an application is deployed from a repository in ArduMaker, resolve conflicts and check the result before sending the branch used in production. An automatic deployment can only run the code it received: it does not know which business decision was correct.

In one sentence: Git can detect when it does not know how to merge changes. Resolving the conflict is deciding the final logic, checking it, and recording the integration.

Sources: Git merge · Merge conflicts in Pro Git.

What is a merge conflict in Git and how to resolve it without losing changes?
  • Git
  • merge
  • conflictos

Keep reading

All articles · VPS plans