To resolve a three-way Git merge conflict in a Linux terminal, inspect the unmerged paths with git status, compare the base and both branch versions, edit each conflicted file into the intended final form, and stage it with git add. Finish with git merge --continue or git commit; use git merge --abort if you need to abandon the merge.
What makes a merge conflict three-way?
Git compares three versions of the relevant content: a common ancestor (the base), the current branch, and the branch being merged in. A conflict occurs when Git cannot combine the changes automatically. In the index, an unresolved path can expose those versions as stage 1 (base), stage 2 (current HEAD), and stage 3 (MERGE_HEAD, the other side).
As an Amazon Associate I earn from qualifying purchases.
For a text conflict, the working-tree file often contains markers such as <<<<<<<, =======, and >>>>>>>. These show competing content, not a decision about which content is correct. Your resolution is the final content you write into the file.
Resolve and complete the merge from the terminal
-
List unresolved paths. Run
git status. Look for paths reported as unmerged; resolve each one rather than assuming the first conflict is the only one.#1 Best Overall
-
Inspect the conflict and surrounding context. Open each path in an editor. Read the full relevant function, paragraph, or configuration—not just the marker-delimited lines. Preserve the intended changes from either or both branches, remove the conflict markers, and save valid final content.
-
Compare the three versions if needed. For a conflicted path, inspect the index entries with
git show :1:path/to/filefor the base,git show :2:path/to/filefor the current branch, andgit show :3:path/to/filefor the incoming branch. Replacepath/to/filewith the actual path.Git also documents
git difffor viewing a three-way comparison of current and merged-in versions. Where theAUTO_MERGEref is available,git diff AUTO_MERGEshows textual resolution work performed so far. To review commits from either side that touched an unresolved path, usegit log --merge -p -- path/to/file.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Stage the resolved path. Run
git add path/to/filefor each file whose final content is ready. Staging tells Git to record your resolution; it is not merely a note that you looked at the file. -
Review, then finish. Check
git statusand review the resulting changes withgit diff --cached. Run the project’s appropriate checks when applicable. When all conflicts are resolved and staged, rungit merge --continueorgit committo complete the merge.git merge --continueverifies that a merge is in progress before proceeding to commit.
Choose the correct content, not simply one side
Do not accept everything between one marker and the separator—or everything below it—without understanding what each branch changed. A valid resolution may combine both changes, keep one, or deliberately replace both with a third result. Check surrounding code or text and project behavior; removing markers only makes the file syntactically cleaner, not necessarily correct.
Rank #4
Also distinguish the -Xours strategy option from the ours merge strategy. The ort strategy option -Xours favors the current side for conflicting hunks while retaining non-conflicting changes from the other tree. The ours strategy ignores the other tree’s contents entirely. These are different choices, and neither is a general substitute for reviewing the merge.
Free tools Windows power users keep installed
One-click scans. No signup required.
When the conflict is not a simple text block
Git can report file-level conflicts or conflicts involving submodules, where editing marker blocks is not the whole resolution. Use git status to identify the path’s state and inspect the path-specific differences before choosing what to keep. Once the path has the intended result, stage it with git add as appropriate.
Best Value
Use a merge tool if it helps
git mergetool can launch a configured external utility after a merge. Run it without path arguments to process conflicted files. Utilities such as meld, vimdiff, and kdiff3 are examples, but availability depends on what is installed and configured on your system. Manual editing and Git’s diff commands are sufficient; no external tool is required.
For a custom tool, Git can provide temporary BASE, LOCAL, and REMOTE inputs when available, and expects the tool to write the resolved result to MERGED. Regardless of the interface, inspect the final file and review the staged diff before completing the merge.
Abort if you need to abandon the merge
Run git merge --abort to attempt to return to the state before the merge began. Git warns that it may not be able to reconstruct all prior changes if you had uncommitted work before the merge, particularly if that work was further modified while resolving conflicts. Starting a merge with a clean working tree when practical reduces this risk.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




