Resolve in VS Code, IntelliJ, GitLab, GitHub
Intermediate VS Code UI IntelliJ UI GitLab UI GitHub UI
Why this matters
Graphical merge tools are genuinely better than editing markers by hand, especially for a long conflict, because they show both sides side by side and let you click. They are also the place where people get lost, because the buttons have names like "ours" and "theirs" without saying which is which. This lesson maps every button onto the four steps you already know from lesson 11.3.
The four steps, whatever the tool
| Step | Terminal | VS Code | IntelliJ |
|---|---|---|---|
| 1. Find the files | git status |
Source Control, Merge Changes group | Files Merged with Conflicts dialog |
| 2. Edit | your editor | inline actions or the merge editor | the three-pane merge tool |
| 3. Mark resolved | git add <file> |
Complete Merge, or stage the file | Apply Changes |
| 4. Finish | git commit |
Commit | Commit |
Nothing else is different. If a tool confuses you, drop to the terminal: the repository is in the same state either way.
How to do it
The reference procedure, from lesson 11.3:
$ git status
$ # edit the file, delete every marker line
$ git add docs/faq.md
$ git commit --no-editEverything the graphical tools do reduces to these four steps, and you can switch between the terminal and a tool at any point in the middle.
VS Code offers two ways: quick inline actions, and the full merge editor.
Inline actions, good for a short conflict:
- Open the conflicted file. Conflicts appear highlighted, with a row of small links above each block.
- The links are Accept Current Change, Accept Incoming Change, Accept Both Changes and Compare Changes. "Current" is your side (
HEAD); "Incoming" is the branch being merged in. - Click one, or ignore them all and edit the text by hand — the markers are ordinary text.
- Save, then stage the file in Source Control (the +), and commit.
The merge editor, better for anything longer:
- In Source Control, conflicted files appear under Merge Changes. Click one, then the Resolve in Merge Editor button (or right-click the file → Open in Merge Editor).
- Three panes appear: Incoming on the left, Current on the right, and Result at the bottom. The Result pane is editable and is what will be saved.
- Each conflict has checkboxes on the two top panes: tick a side to include it, tick both to include both. Then correct the Result pane by hand if the combination needs editing.
- When every conflict is handled, click Complete Merge. VS Code saves the file and stages it.
- Commit from Source Control as usual.
IntelliJ notices the conflict and offers a dialog before you open anything.
- The Files Merged with Conflicts dialog lists the conflicted files with three choices: Accept Yours, Accept Theirs (whole-file decisions, useful for binaries) and Merge, which opens the merge tool for a real resolution.
- The merge tool has three panes: your local version on the left, the incoming repository version on the right, both read-only, and an editable result in the centre.
- Use the chevrons and X icons beside each change to Accept or Ignore it from either side; the centre pane updates as you go. Apply All Non-Conflicting Changes in the toolbar handles everything unambiguous in one click, leaving only the real decisions.
- For a whole conflict, the context menu offers Resolve using Left and Resolve using Right.
- Edit the centre pane freely to write a combined result.
- Click Apply Changes when the file is done. Repeat for the remaining files, then commit.
If you reach the dialog again later, Git → Resolve Conflicts… reopens it; Git → Abort Merge is the equivalent of git merge --abort.
A merge request whose branch conflicts with its target shows There are merge conflicts and, when the conflict is simple enough, a Resolve conflicts button offering two modes:
- Interactive mode, which shows each conflict with Use ours and Use theirs buttons. Whole-side choices only.
- Edit inline, which gives you the file with markers in a text box, like editing by hand.
Committing there creates a merge commit on your branch and the merge request updates.
GitLab refuses the browser resolution when the conflict is too complex, when the file is binary, or when the merge request has more than a handful of conflicting files. The message tells you to resolve locally, and the merge request page shows the exact commands to do so.
A pull request with conflicts shows This branch has conflicts that must be resolved and, for text files, a Resolve conflicts button that opens a web editor containing the file with its markers.
You edit the text, delete every marker line, and click Mark as resolved for each file, then Commit merge. GitHub commits the resolution onto your branch.
As on GitLab, the button is unavailable for binary files, for very large conflicts and for some rename cases; GitHub then shows the command-line instructions instead.
Choosing a tool
| Situation | Best tool |
|---|---|
| One or two lines of prose | inline actions in your editor, or the browser |
| A long conflict, several blocks | VS Code merge editor or IntelliJ's merge tool |
| Many files at once | IntelliJ's dialog with Apply All Non-Conflicting Changes |
| Binary file | any tool's "take one side" option, or git checkout --ours/--theirs |
| Anything you need to test afterwards | locally, in the terminal or an IDE |
Common mistakes
- Assuming "Current" and "Yours" mean your branch in every context. They do during a merge; during a rebase the sides are swapped (lesson 11.5). When unsure, read the actual text rather than the label.
- Clicking "Accept Both" and committing. The result is often duplicated sentences or code that does not compile; read the Result pane.
- Resolving code in the browser. Nothing is compiled or tested there.
- Forgetting the remaining files. Tools resolve one file at a time;
git statusis the reliable list of what is left. - Leaving the merge editor without Complete Merge. The file may be edited but not staged, so the commit is refused.
Try it yourself
Goal: resolve the same conflict twice, once with a tool and once by hand.
- Create the FAQ conflict from lesson 11.1 and start the merge.
- Resolve it in your IDE: VS Code's merge editor or IntelliJ's merge tool. Note which pane is yours.
- Before committing, run
git statusin the terminal and confirm the file is staged. - Abort with
git merge --abortand create the conflict again. - Resolve it by hand this time, with
git addandgit commit.
Expected result: both routes end in the same commit; step 3 shows the tool ran git add for you.
Show solution
Step 3 is the point: the graphical tool is a nicer front end to the same index. Once you have seen that its "done" button is git add, switching between the terminal and the tool mid-conflict stops feeling risky.