Skip to main content
BERTA MATULIAUSKIENE@Berta.codes
  • AI ADOPTION
  • PERSONAL BRAND
  • BLOG
  • ABOUT
  • RESOURCES
    • SETUP
    • AI PROMPTS
    • APPS
  • AI ADOPTION
  • PERSONAL BRAND
  • BLOG
  • ABOUT
  • RESOURCES
    • SETUP
    • AI PROMPTS
    • APPS
Appearance
Find Me Online

Find me online

Explore

  • About Berta
  • Articles
  • Newsletter

Resources

  • AI prompt library
  • My apps

Consulting

  • Practical AI adoption
  • Personal brand review
  • hello@bertacodes.com

STAY CURIOUS

PrivacyRSS feed

© 2026 BERTA CODES

Back to blog
GitVS CodeDevelopment

Git Conflicts in VS Code: A Beginner-Friendly Guide

Learn how to handle Git conflicts in VS Code with confidence - perfect for junior developers.

March 20, 2025
Updated October 23, 2026
Berta Matuliauskiene
10 min read
Git Conflicts in VS Code: A Beginner-Friendly Guide

Reviewed on October 23, 2026 against the Git and VS Code documentation linked below. This update corrects the recovery advice, merge/rebase terminology, keyboard shortcuts, and formatting. Menu labels can vary with your VS Code version and extensions.

Prerequisites#

Before getting started, make sure you have:

  • VS Code installed.
  • Git installed and configured.
  • A basic understanding of commits and branches.

Before starting a merge or rebase, commit or stash unfinished work. If you already have a conflict, inspect the current state first rather than starting another operation.

Quick Start Guide#

Got a conflict right now? Here's what to do:

  1. Don't panic! A conflict means Git needs a decision about the result.
  2. Run git status in your repository to see which operation stopped and which files need attention.
  3. Open Source Control in VS Code and find the conflicted files under Merge Changes.
  4. Open a file, compare both versions, and decide what the final code should do. Use the inline actions or the Merge Editor.
  5. Save the resolved file, stage it, and repeat for the other conflicts.
  6. Review the staged changes and run the relevant tests before completing the merge or continuing the rebase.

The details below focus on text conflicts during a merge or rebase. A deleted or renamed file may need a different decision from choosing lines of code.

Understanding Git Conflicts (The Basics)#

What's a Conflict?#

Imagine you and your friend are editing the same document:

  • You change a line to say "Hello World".
  • Your friend changes the same line to say "Hi there".
  • Git cannot decide which greeting the finished document should contain.

That's a conflict! It doesn't mean either person did something wrong. You need to decide which version, or combination, matches the intended behavior.

When Do Conflicts Happen?#

Branches can develop from a shared starting point:

             C → D  feature
            /
A → B → E → F       main

When changes overlap, combining those branches can require a decision. Conflicts can also happen while replaying commits during a rebase, applying a cherry-pick, or restoring a stash.

VS Code's Conflict Tools#

Finding Conflicted Files#

Use the Source Control view's Merge Changes group. File decorations can differ by theme and version, so don't rely on a particular color or badge. git status is also useful when the editor view is unclear.

Conflict Markers Explained#

For a merge, a conflicting section might look like this:

<<<<<<< HEAD
console.log("Hello World");
=======
console.log("Hi there");
>>>>>>> feature/greetings

The first section is the current side; the second is the incoming side. These labels describe Git's operation, not who wrote the code.

  • During a merge, current/ours is the branch you checked out, and incoming/theirs is the branch being merged into it.
  • During a rebase, current/ours is the new base plus any commits already replayed. Incoming/theirs is the commit from your branch that Git is replaying. Your feature changes may therefore be on the incoming side.

Read the code and the operation's context before accepting a side. Git documents this reversal in its rebase reference.

Step-by-Step Resolution#

1. Open the Conflicted File#

Select the Source Control icon in VS Code's sidebar. The default shortcut is Ctrl+Shift+G on Windows/Linux and Control+Shift+G on macOS. On macOS, that is Control, not Command.

Open a file under Merge Changes. For a larger conflict, right-click it and choose Open in Merge Editor. Some versions also offer Resolve in Merge Editor within the open file.

2. Review the Result#

The Merge Editor shows incoming, current, and result views. Layouts can change, so follow the labels rather than assuming that your changes are always on the left.

Compare the inputs, choose the changes that belong in the result, and edit that result when neither side is sufficient. For the documented controls and layouts, see VS Code's merge-conflict guide.

3. Make a Decision for Each Conflict#

In the ordinary text editor, the inline conflict actions let you keep current changes, incoming changes, or both. You can also compare the versions or edit the file yourself.

Accepting both is not an automatic solution. Two greetings might be harmless in a document, but two declarations with the same name can break a program. Remove conflict markers and check the complete function, not only the highlighted lines.

4. Stage, Test, and Finish the Right Operation#

Save each resolved file and stage it in Source Control. The Merge Editor's Complete Merge action stages that file; it does not necessarily finish the operation for the whole repository.

Before continuing, inspect what is staged:

git status
git diff --cached

Run the project's relevant tests. Then use the action for the operation reported by git status:

  • For a merge, create the merge commit in Source Control or use git merge --continue.
  • For a rebase, use git rebase --continue. Another commit may conflict; resolve it and repeat until Git finishes.
  • If Git reports a different operation, follow its instructions instead of using the merge command by habit.

Git's merge reference and rebase reference explain the continuation steps.

Real-World Examples#

1. Simple Text Conflict#

<<<<<<< HEAD
const greeting = "Hello";
=======
const greeting = "Hi";
>>>>>>> feature/greetings

Ask which greeting the product needs. If it should say "Hi", the resolved file contains one declaration:

const greeting = 'Hi';

Keeping both declarations would not be a valid resolution. The absence of conflict markers alone doesn't prove that the result works.

2. React Component Conflict#

function Button() {
<<<<<<< HEAD
  return <button className="blue">Click me</button>;
=======
  return <button className="red">Press here</button>;
>>>>>>> feature/styling
}

Think about the intended change:

  • Which style should the button use?
  • Which text belongs in the interface?
  • Did either branch change related styles or behavior elsewhere?

If the team wants the blue style and the new text, combine those choices deliberately:

function Button() {
  return <button className="blue">Press here</button>;
}

Then check the button in context. A resolution can be valid JavaScript and still be the wrong product decision.

Common Mistakes to Avoid#

Mistake 1: Closing VS Code and Hoping the Conflict Disappears#

Closing the editor does not resolve the repository state. Reopen the project, check git status, and work through the files one at a time.

Mistake 2: Accepting a Whole Side Blindly#

A button can remove the conflict markers while also removing a change you needed. Review each conflict and the final diff. During a rebase, double-check what current and incoming represent.

Mistake 3: Forgetting to Test#

Two changes can fit together textually but disagree in behavior. Run relevant tests and check the affected feature before committing or continuing.

Best Practices (Your Conflict Checklist)#

Before Resolution#

  • Understand which operation is in progress.
  • Read what both changes were trying to achieve.
  • Ask a teammate when the intended behavior is unclear.

During Resolution#

  • Review each conflicted file.
  • Combine the necessary behavior, not just the lines.
  • Save and stage each resolution after checking it.

After Resolution#

  • Review the staged diff for missing or duplicated changes.
  • Run the relevant tests.
  • Complete the merge or continue the rebase, as appropriate.
  • Follow your team's review and publishing workflow.

Preventing Conflicts#

Keep Work Small and Communicate#

Tell teammates which areas you are changing, particularly during a refactor. Small, focused branches are usually easier to review and reconcile than weeks of unrelated edits.

Update With Your Team's Workflow#

Agree how your team brings shared changes into a feature branch. A merge and a rebase affect history differently. Check your branch and save unfinished work before updating; don't copy a daily git pull origin main command without knowing which branch it will update and how pull is configured.

Keeping up to date can make conflicts smaller, but it cannot guarantee that you avoid them.

Need Help?#

If You Get Stuck#

Pause before trying more commands. Compare both versions, read the surrounding code, and ask a teammate to help decide what the result should do.

These inspection commands do not discard your work:

git status
git diff
git diff --cached

If You Need to Stop the Operation#

First copy any edits you want to retain to a safe place outside the repository. Aborting can remove the conflict-resolution work you have just done. Check git status, then choose only the command for the operation in progress:

  • git merge --abort attempts to return to the state before the merge. If you had uncommitted changes before starting, Git may not be able to reconstruct all of them. See the merge-abort documentation.
  • git rebase --abort cancels the rebase and resets the branch to where the rebase began. See the rebase-abort documentation.

Do not use git reset --hard HEAD as a general recovery step. It discards staged and unstaged changes to tracked files, including unfinished conflict resolutions, and can overwrite untracked files that obstruct restoring tracked paths. Those changes may not be recoverable through Git. The reset documentation explains the behavior.

If abort fails or you are unsure what will be lost, keep your copy and ask for help before resetting anything.

Optional Extensions for Understanding History#

VS Code's built-in tools can resolve conflicts without extra extensions. If understanding the history is the hard part, these optional tools can help:

  • GitLens, extension ID eamodio.gitlens: inspect line authorship and history to understand the context behind a change.
  • Git History, extension ID donjayamanne.githistory: browse file history and compare commits or branches.
  • Git Graph, extension ID mhutchie.git-graph: visualize branches and commits when their relationship is hard to follow.

Use the Extensions view to find the exact extension and review its publisher and documentation before installing. Start with one tool that solves a problem you actually have. A history view can explain a change; it cannot decide the correct behavior for your project.

Finding Commands and Keyboard Shortcuts#

There is no universal set of conflict shortcuts shared by these extensions. Use commands by name first, then assign shortcuts if you use them often:

  • Open the Command Palette with Ctrl+Shift+P on Windows/Linux or Command+Shift+P on macOS.
  • Search for the installed tool's commands, such as GitLens or Git Graph, rather than relying on a shortcut from someone else's setup.
  • Open Preferences: Open Keyboard Shortcuts to see or change bindings for your installation.
  • Check a command's current binding before assigning a key combination that may already have another job.

VS Code's keyboard shortcuts documentation explains how defaults, extensions, and custom keymaps interact.

Practice Makes Perfect#

Try resolving a small conflict in a disposable practice repository before doing it under pressure:

  1. Make two branches from the same commit.
  2. Change the same line differently on each branch and commit each change.
  3. Merge one branch into the other and inspect the conflict.
  4. Choose a result, review it, and complete the merge.
  5. Repeat with a change where the correct result combines parts of both versions.

The goal is to understand the decision, not memorize which button to press. That confidence carries over to more complicated conflicts.

Resources for Learning More#

  • VS Code: Resolve merge conflicts
  • Git: How to resolve merge conflicts
  • Git: Rebasing
  • VS Code: Keyboard shortcuts

Share this post

Previous Article

Trunk-Based Development: A Guide for Beg...

Next Article

Learning to Code Was Never the Point. Le...

You might also like

Trunk-Based Development: A Guide for Beginners

Trunk-Based Development: A Guide for Beginners

March 19, 2025

How to Start Using AI at Work: Choose One Task You Can Check

How to Start Using AI at Work: Choose One Task You Can Check

October 23, 2026

A Personal Brand Profile Review: What Should a Stranger Understand?

October 23, 2026

Table of Contents

  • Prerequisites
  • Quick Start Guide
  • Understanding Git Conflicts (The Basics)
  • VS Code's Conflict Tools
  • Step-by-Step Resolution
  • Real-World Examples
  • Common Mistakes to Avoid
  • Best Practices (Your Conflict Checklist)
  • Preventing Conflicts
  • Need Help?
  • Optional Extensions for Understanding History
  • Practice Makes Perfect
  • Resources for Learning More

Recent Posts

  • How to Start Using AI at Work: Choose One Task You Can Check
    October 23, 2026
  • A Personal Brand Profile Review: What Should a Stranger Understand?
    October 23, 2026
  • Harness Engineering: Building Our Own Tools While Teaching AI How We Work
    October 21, 2026
  • AI Automation: The Biggest Challenge Is Not How, but What, Where, When, and How Much
    October 17, 2026
  • When Human in the Loop Becomes Theatre
    October 8, 2026