AutoDeploy
← All guides

Git

LOWOtherBEGINNER

Git Merge Conflict Resolution

Merging or rebasing fails with conflict markers because the same lines changed differently on both sides.

Est. Time

20 minutes

Version

v1.0.0

Updated

7/25/2026

Author

AutoDeploy Team

Tags

#git#merge#conflict#version-control

Prerequisites

  • Git installed
  • Local clone of the repository

Setup Guide

Download guide

Git Merge Conflict Resolution

Problem

Merging or rebasing branches fails with conflict markers because the same lines were changed differently on both sides.

Symptoms

  • CONFLICT (content): Merge conflict in <file>
  • git status shows files as "both modified"
  • <<<<<<<, =======, >>>>>>> markers appear in the file

Root Cause

Two branches modified the same lines (or one deleted a file the other modified) and Git can't automatically decide which change should win.

Solution

1. See which files are conflicted

git status

2. Open each conflicted file and find the markers

<<<<<<< HEAD
your changes
=======
their changes
>>>>>>> branch-name

3. Edit the file to the correct final content, removing all markers

4. Stage the resolved file

git add <file>

5. Continue the merge or rebase

git merge --continue
# or
git rebase --continue

6. If you want to abandon and start over

git merge --abort
# or
git rebase --abort

7. For a visual diff/merge tool instead of manual editing

git mergetool

Prevention

  • Pull/rebase from the target branch frequently instead of letting branches diverge for weeks
  • Keep pull requests small and short-lived so overlap windows are smaller
  • Agree on file/module ownership within a team to reduce simultaneous edits to the same lines
  • Use git rerere to have Git remember how you resolved a conflict last time

References

Last updated on 7/25/2026 · Part of the AutoDeploy DevOps Documentation library