Skip to main content
March 23, 2026Dan Rodney/3 min read

How to Handle Merge Conflicts

Master Git conflicts with confidence and precision

What You'll Learn

This guide covers the essential steps for identifying, understanding, and resolving Git merge conflicts that occur when multiple developers work on the same codebase.

Common Merge Conflict Scenarios

Parallel Development

Multiple developers editing the same file sections simultaneously. This creates conflicting changes that Git cannot automatically resolve.

Branch Merging

Conflicts arise when merging feature branches back into main branches. Different implementations of the same functionality require manual resolution.

Pull Operations

Remote changes conflict with local modifications during pull requests. Your local work clashes with updates from the remote repository.

Merging Changes

Merge conflicts are an inevitable part of collaborative development—and often a sign of a healthy, active codebase. They occur when Git encounters competing changes to the same section of code during pulls, branch merges, reverts, or cherry-picks. Picture this scenario: you're refactoring a critical function while a teammate simultaneously optimizes the same code block. When they push first and you attempt to pull their changes, Git wisely pauses the merge rather than making assumptions about which version to keep. This conflict resolution mechanism is one of Git's most valuable features, ensuring that no developer's work is silently overwritten and giving you complete control over how competing changes are reconciled.

Understanding how to efficiently resolve merge conflicts separates novice developers from seasoned professionals. The process requires both technical precision and collaborative judgment—skills that become increasingly valuable as codebases grow and teams expand.

How Merge Conflicts Develop

Step 1

Initial State

Both developers start with the same version of the file

Step 2

Parallel Changes

Each developer modifies the same section independently

Step 3

First Push

Developer A pushes changes to remote repository

Step 4

Conflict Occurs

Developer B attempts to pull and encounters merge conflict

Prevention Strategy

Regular communication between team members and frequent pulls from the main branch can significantly reduce the frequency of merge conflicts.

What to Do with a Merge Conflict

  1. When Git detects conflicting changes, it will halt the merge operation and clearly identify the affected files. Navigate to the conflicted file by opening the Source Control panel vscode soure control icon and locating the files listed under Merge Changes. These files are marked with a distinctive conflict indicator, making them immediately recognizable in your IDE.
  2. Open the conflicted file to examine Git's conflict markers, which function as a roadmap to the competing changes:

    <<<<<<< HEAD (Current Change) Marks the beginning of your local changes—the version currently in your working branch.

    ======= Serves as the dividing line between your changes and the incoming modifications from the other branch.

    >>>>>>> branch-name (Incoming Change) Marks the end of the conflict block and identifies the source branch of the competing changes.

  3. This is where your expertise and judgment become crucial. Modern IDEs like VS Code present intuitive options above each conflict block to streamline your decision-making:

    • Accept Current Change — Keep your version and discard the incoming changes
    • Accept Incoming Change — Adopt the other developer's modifications
    • Accept Both Changes — Merge both versions (use cautiously to avoid duplication)
    • Compare Changes — View a side-by-side diff for detailed analysis

    Evaluate the code contextually: consider functionality, performance implications, coding standards, and the broader impact on your application. Often, the best resolution involves manually combining elements from both versions or crafting an entirely new approach that incorporates the strengths of each. After selecting your preferred resolution, refine the code as needed to ensure it integrates seamlessly with your project's architecture.

  4. Save the resolved file, ensuring all conflict markers have been removed and the code compiles correctly.
  5. Once all conflicts across your project have been addressed, return to the Source Control panel vscode soure control icon to stage your resolution. Hover over Merge Changes and click the plus (+) icon that appears. This action tells Git that you've deliberately resolved the conflicts and are ready to proceed with the merge.
  6. Complete the merge process by clicking the Commit button vscode commit icon at the top of the Source Control panel vscode soure control icon. Consider crafting a descriptive commit message that explains how you resolved the conflict—future developers (including yourself) will appreciate this context.
  7. Push your resolved changes to the remote repository when you're confident in the resolution. This final step makes your conflict resolution available to the entire team and ensures the project maintains forward momentum. Remember, thoroughly test your merged code before pushing—conflict resolution can sometimes introduce subtle integration issues that only surface during runtime.

Conflict Resolution Process

1

Identify Conflicted Files

Open the Source Control panel and locate files listed under Merge Changes section

2

Understand Conflict Markers

Locate HEAD markers for current changes, equals signs as dividers, and branch-name markers for incoming changes

3

Choose Resolution Strategy

Select from Accept Current Change, Accept Incoming Change, Accept Both Changes, or Compare Changes options

4

Make Additional Edits

Refine the code after accepting changes to ensure proper functionality and code quality

5

Stage and Commit

Save files, stage changes using the plus button, and commit the resolved conflicts

Conflict Marker Guide

HEAD Current Change

Seven less-than symbols mark the beginning of your local changes. These represent the modifications you made in your working branch.

Separator Line

Seven equals signs divide your changes from incoming changes. This clearly separates the two conflicting versions of the code.

Branch Incoming Change

Seven greater-than symbols with branch name mark the end of incoming changes. These are modifications from the remote repository.

Resolution Options Comparison

FeatureStrategyUse CaseOutcome
Accept Current ChangeKeep your local modificationsYour implementation is correctDiscards incoming changes
Accept Incoming ChangeKeep remote repository changesRemote version is preferredDiscards your local changes
Accept Both ChangesCombine both modificationsBoth changes are neededMerges all modifications
Compare ChangesReview differences side-by-sideNeed detailed analysisEnables informed decision
Recommended: Accept Both Changes is often the most comprehensive approach, allowing you to incorporate all modifications while making manual adjustments.

Post-Resolution Checklist

0/5

Key Takeaways

1Merge conflicts occur when multiple developers modify the same file sections, requiring manual resolution to combine changes effectively.
2Git provides clear conflict markers including HEAD for current changes, equals signs as separators, and branch names for incoming modifications.
3The Source Control panel lists all conflicted files under the Merge Changes section for easy identification and access.
4Four primary resolution strategies exist: accepting current changes, accepting incoming changes, accepting both, or comparing differences side-by-side.
5After choosing a resolution strategy, additional manual edits may be necessary to ensure code quality and proper functionality.
6The complete resolution process involves saving files, staging changes with the plus button, committing with descriptive messages, and pushing to remote repositories.
7Regular communication between team members and frequent pulls can significantly reduce the frequency and complexity of merge conflicts.
8Testing functionality after resolving conflicts is crucial to ensure that combined changes work correctly and don't introduce new bugs.

RELATED ARTICLES