Cheat Sheets · Git Cheat Sheet · Git Resolve Merge Conflict — Complete Workflow
Git Resolve Merge Conflict — Complete Workflow
1. Check statusgit status
2. Edit filesManual / IDE
3. Stage resolvedgit add
4. Complete mergegit commit
Abort if neededgit merge --abort
Conflict resolution workflow
| Step | Command | Description |
|---|---|---|
1. Check status | git status | Identify all files marked "both modified" |
2. Edit files | Manual / IDE | Open files, choose content, remove <<<<<<<, =======, >>>>>>> markers |
3. Stage resolved | git add <file> | Mark conflict as resolved in Git index |
4. Complete merge | git commit | Finalize merge commit with default message |
Abort if needed | git merge --abort | Cancel merge and revert to pre-merge state |
Merge conflicts occur when two branches modify the same lines of a file. Git pauses and inserts conflict markers so you can decide which version to keep.
Related Git recipes
Undo Last Commit — 3 Safe Ways
Discard Local Changes — Safely and Completely
Delete a Branch — Local and Remote
Stash — Park Changes Without Committing
Amend the Last Commit
Undo a Pushed Commit — The Safe Way (git revert)
Rename Local Branch — Safely & Quickly
Rename Remote Branch — Complete 3-Step Process
Cherry Pick — Apply a Specific Commit Elsewhere
Squash Last N Commits — Combine Multiple Commits
Sync Fork with Upstream — Step-by-Step
Delete Remote Tag — Local and Remote
Change Commit Author — Email & Name
Unstage File — Remove from Staging Area
Log Graph — Visual Commit History in Terminal
Clean Untracked Files — Remove Clutter Safely
Switch Branch — Modern Branch Navigation
Create Branch from Commit — Branch Off History
Stash Untracked Files (-u and -a Flags)
Force Pull — Overwrite Local Changes with Remote
Show Commit — Inspect Changes in a Commit
Tag a Release — Lightweight & Annotated Tags
FAQ
What does <<<<<<< HEAD mean?
HEAD marks the code currently on your active branch. The code after ======= and before >>>>>>> comes from the branch you are merging in.
How do I abort a conflict during a rebase?
Run git rebase --abort.
Can I choose one branch's version entirely?
Yes: git checkout --ours keeps current branch, git checkout --theirs accepts incoming branch.
Stop memorizing — build it interactively
Try conflict resolution in the Git BuilderFull reference: Git Cheat Sheet