Developer and Text Tools

How to Resolve Git Merge Conflicts Calmly, Hunk by Hunk

Read git conflict markers, use diff3 to see the common base, decide between ours and theirs for each hunk, and finish the merge with a clean file.

Saizul Amin
Saizul Amin7 Nov 2026 · 4 min read
How to Resolve Git Merge Conflicts Calmly, Hunk by Hunk

A merge conflict looks alarming the first time: angle brackets and equals signs scattered through a file, and git refusing to continue. In reality a conflict is git being careful. It found two changes to the same lines and would rather ask you than guess. Once you can read the markers, most conflicts take a minute to settle.

Reading the markers

Git wraps each conflicting block, called a hunk, in markers. A line of seven less-than signs starts it, followed by the name of your side, usually HEAD. Then come your lines, a line of seven equals signs, the incoming lines, and a line of seven greater-than signs with the name of the other branch. Everything outside the markers merged without trouble.

Your job is to replace each hunk, markers included, with the lines that should be there. Sometimes that is one side, sometimes both, and sometimes a mix you write yourself.

Turn on diff3

The default style shows only the two results, not where they started. That makes it hard to tell who changed what. Run git config --global merge.conflictStyle diff3, or zdiff3 on git 2.35 and later, and git adds a third section after a line of seven pipes: the common base. Now you can see that the base said port = 80, you changed it to 8080 and the other branch left it alone. The answer is obvious, and the decision becomes mechanical.

Ours and theirs

During a merge, ours is the branch you are on and theirs is the branch coming in. During a rebase they swap, because git is replaying your commits on top of the other branch: ours is the branch you are rebasing onto and theirs is your own commit. When in doubt, read the labels on the markers rather than trusting the words.

Resolving in the browser

The free Git Merge Conflict Resolver reads files with conflict markers in all three styles, any marker length and either line ending, and several files at once. Each hunk is shown as side-by-side cards, ours, base and theirs, with the differing lines highlighted. On a phone the cards stack, and every button is big enough to tap.

The tool classifies every hunk. If both sides made the same change, either side is right. If only one side changed since the base, that side wins. If the sides differ only in whitespace, either is safe. If both sides added different lines at the same place, keeping both is often correct. If one side deleted a block the other edited, or both changed the same lines differently, it waits for you.

Press Auto-resolve safe hunks and only the clear cases are settled. For the rest, choose ours, theirs, both in either order, the base, or edit the block by hand in a text box that starts with both sides combined. A Next unresolved button takes you straight to the hunks still waiting.

A worked example

The diff3 sample, a small settings.ini, has three hunks. In the first, the base port was 80, ours is 8080 and theirs unchanged, so auto-resolve keeps 8080. The second is a real conflict over a timeout: base 10, ours 30, theirs 60. Someone has to decide, so pick the value the team agreed. The third has an empty base and two different additions under the log section, one setting the level and one the format, and keeping both is right. Three decisions, and the file is clean.

Finishing the merge

The resolved file view shows the assembled result and warns, with line numbers, if any marker is left. Line endings and the final newline are kept exactly as they were, so your commit does not include accidental whitespace changes. Save the file, then run git add on it and git merge --continue, or git rebase --continue during a rebase.

Before committing, run the tests. A conflict tool works on lines of text and cannot know whether the merged code compiles or behaves correctly. The copy report button lists each hunk and the choice you made, which is worth pasting into the commit message or pull request so reviewers know how the conflict was settled.

Fewer conflicts next time

Merge or rebase from the main branch often, keep pull requests small, and agree on formatting tools so whitespace never causes a conflict. Conflicts will still happen, but they will be small, clear and quick to settle.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages