A merge conflict happens when Git cannot automatically combine changes from two branches. This typically occurs when two branches modify the same lines, one branch deletes a file another branch modifies, or both branches add content at the same location.
VS Code gives you three ways to resolve conflicts: inline CodeLens actions for simple conflicts, a 3-way merge editor for complex ones, and AI-assisted resolution if you have Copilot. Read /vscode/how-to-create-switch-and-merge-git-branches-in-vs-code for the branch workflow that leads up to merging.
Recognize conflicts
When a merge, rebase, or pull triggers conflicts, VS Code shows several indicators:
- The Source Control view displays a Merge Changes section listing all conflicted files.
- The Status Bar shows the merge state.
- Conflicted files open with inline markers:
<<<<<<<(current branch),=======(separator), and>>>>>>>(incoming branch).
Select any conflicted file in the Source Control view to open it. VS Code highlights the conflicting sections and shows CodeLens action buttons above each conflict.
Resolve simple conflicts inline
For straightforward conflicts, use the CodeLens buttons directly in the editor.
Open a conflicted file
Select the file from the Merge Changes section in the Source Control view.
Review the conflicting sections
Each conflict is marked with colored highlighting. The top section (between <<<<<<< and =======) is your current branch. The bottom section (between ======= and >>>>>>>) is the incoming branch.
Choose a resolution
Above each conflict, select one of the CodeLens actions:
- Accept Current Change: keep your branch's version
- Accept Incoming Change: keep the incoming branch's version
- Accept Both Changes: keep both versions, one after the other
- Compare Changes: open a diff view to inspect the differences
Save the file
After resolving every conflict in the file, the markers disappear. Save the file with Ctrl+S (macOS: Cmd+S).
For conflicts where you need a mix of both versions, you can edit the file manually. Delete the conflict markers and write the combined content you want. Save when done.
Use the 3-way merge editor
For complex conflicts with many overlapping changes, the 3-way merge editor gives you a side-by-side view.
Open the merge editor
Select a conflicted file in the Source Control view, then select the Resolve in Merge Editor button that appears at the top of the editor. You can also right-click the file and choose Open in Merge Editor.
Understand the layout
The merge editor has three panels:
- Incoming (left): changes from the branch being merged in
- Current (right): changes from your current branch
- Result (bottom): the combined file that will be saved
Accept or ignore changes
Each conflicting change has checkboxes. Use them to select which version to keep. You can also use the CodeLens actions above each conflict: Accept Incoming, Accept Current, Accept Combination, or Ignore.
Edit the result directly
Select anywhere in the Result panel to type. You can combine parts of both changes or write new content. The conflict counter in the top-right shows how many unresolved conflicts remain.
Complete the merge
When the conflict counter reaches zero, select Complete Merge at the bottom of the editor. The file stages automatically and the merge editor closes.
Use the three-dot menu in the merge editor to switch to a vertical layout or show the base view, which displays the file state before any changes were made.
Resolve conflicts with AI
If you have a GitHub Copilot subscription, VS Code can use AI to resolve conflicts automatically.
Open a conflicted file and select the Resolve Merge Conflict with AI button at the top. VS Code analyzes the merge base, the current changes, and the incoming changes, then proposes a resolution in the Chat view. Review the proposed changes and accept or adjust them.
This is an experimental feature and works best when both sides of the conflict represent clear, independent intent.
Complete or cancel the merge
After resolving all conflicts, every file moves to the Staged Changes section in the Source Control view. Enter a commit message describing the merge and select Commit to finalize it.
To abandon the merge entirely, open the Command Palette and run Git: Abort Merge. This returns your repository to the state it was in before the merge started. All conflict markers disappear and no changes are committed.
Once you are comfortable resolving conflicts, learn how to /vscode/how-to-view-git-history-blame-and-the-source-control-graph-in-vs-code to inspect your commit history.
Rune AI
Key Insights
- Conflicted files appear under a Merge Changes section in the Source Control view.
- Use CodeLens buttons (Accept Current Change, Accept Incoming Change, Accept Both Changes) for quick inline resolution.
- Open the 3-way merge editor for side-by-side comparison of Incoming, Current, and Result.
- Use checkboxes in the merge editor to select which changes to keep.
- AI-assisted resolution is available with a Copilot subscription (experimental feature).
- Complete the merge by staging resolved files and committing.
- Run Git: Abort Merge to cancel the merge and restore your previous state.
Frequently Asked Questions
What do the <<<<<<<, =======, and >>>>>>> markers mean in a file?
How do I cancel a merge if I change my mind?
Can VS Code resolve conflicts automatically with AI?
What is the difference between inline resolution and the merge editor?
Conclusion
VS Code gives you three ways to resolve merge conflicts: inline CodeLens actions for quick fixes, the 3-way merge editor for complex conflicts, and AI-assisted resolution if you have Copilot. After resolving all conflicts, stage the files and commit to complete the merge.
More in this topic
How to Use VS Code with WSL 2 on Windows
Run VS Code connected to Windows Subsystem for Linux so you can develop in a full Linux environment with native tools, terminals, and debugging, all from Windows.
20 Best VS Code Extensions for Web Developers in 2026
Twenty carefully chosen VS Code extensions every web developer should know. Covers formatting, linting, frameworks, debugging, Git, and developer experience.
How to Install, Disable, Update, and Uninstall VS Code Extensions
Learn how to install, disable, update, and uninstall VS Code extensions from the Marketplace and the command line. Step-by-step instructions for every action.