Learn

GuideCoding & GitCompanion to Git

Git conflicts and undoing mistakes: a beginner's decision guide

A merge conflict means Git cannot combine competing changes automatically. It needs someone to decide what the finished result should be. A conflict can arise when two changes edit the same lines, or when one deletes a file that the other edits. [1]

Git has identified a disagreement. The next job is understanding it.

Two sensible edits can collide

Our fictional plant-swap page begins with the heading “Saturday plant swap.” One bot adds the time: “Saturday plant swap · 10 a.m.” Another changes the heading to “Community plant swap this Saturday.”

The intended result might combine both ideas: “Community plant swap this Saturday · 10 a.m.” Choosing one bot's entire version would lose the other's contribution.

Two competing heading edits are combined into a reviewed heading that preserves the community wording and the 10 a.m. start time.

Swipe sideways to see the whole diagram, or open it full size.

Combine the intended changes. Resolving a conflict means deciding what the finished result should say.

Figure explanation: The original heading says “Saturday plant swap.” Bot 1 adds “10 a.m.” Bot 2 changes the heading to “Community plant swap this Saturday.” The reviewed result combines both useful intentions: “Community plant swap this Saturday · 10 a.m.” A person confirms the wording and time; the bot checks the result.

Ask the bot to show the original, both proposed versions, and its suggested result. It should explain what each version was trying to accomplish. If the intentions disagree, make that product decision before asking it to finish the merge.

Some editors offer choices such as keeping the current change, incoming change, or both. These are editing shortcuts. “Keep both” may duplicate content or produce invalid code. The finished result still needs review and relevant checks. [4]

Sources

All sources checked September 25, 2026. The fictional example, decision table, and recovery questions are original editorial guidance.

  1. GitHub: Merge conflicts
  2. Git: git-revert
  3. Git: git-status
  4. Visual Studio Code: Resolve merge conflicts

Cookie preferences