October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Use diff3 to Resolve Merge Conflicts in Git

Git’s diff3 conflict style adds the common ancestor’s text to merge conflict blocks, helping you compare both changes before editing and staging the final result.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To use diff3 in Git, enable the diff3 conflict style, then compare the current change and incoming change with the common ancestor’s text. Edit each conflicted passage into the intended final content, remove its markers, stage the file, and finish or continue the merge. diff3 adds context; it does not choose the resolution for you.

Enable diff3 conflict markers

Git’s merge.conflictStyle setting controls how it formats conflicted sections in working-tree files. Set it globally to use diff3 in repositories for your user account:

git config --global merge.conflictStyle diff3

To apply the preference only to the current repository, run the same command there without --global:

git config merge.conflictStyle diff3

Git documents this setting and the available conflict styles in its git-merge documentation; the Pro Git advanced merging chapter also demonstrates configuring diff3.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read a diff3 conflict block

After a merge produces conflicts, open an affected file. A diff3-style block has four markers that divide the passage into three versions:

  • <<<<<<< begins the current side’s version.
  • ||||||| begins the common ancestor’s original text.
  • ======= separates the base text from the incoming side’s version.
  • >>>>>>> ends the block after the incoming side’s version.

The text between the opening marker and the base marker is the current side; the text between the separator and the closing marker is the incoming side. The base section is not a fourth option or “theirs”—it shows what the two sides started from. Marker labels can vary with the merge operation and Git version, so use their positions and roles to interpret the block.

Edit the conflict into the intended result

  1. Compare both changed versions with the base text to understand what each side changed.
  2. Edit the whole conflicted block into the final content the project should contain. You may keep one side, combine parts of both, or write a different result.
  3. Delete all conflict markers and any unwanted alternative text. Save the file, then inspect it to confirm the result reads or works as intended.

Repeat for every conflicted passage and file. Once a file is resolved, stage it:

git add path/to/file

After staging all resolved files, finish the merge with git commit. If Git reports that a merge is in progress and needs to be completed, use git merge --continue. To abandon an in-progress merge instead, Git documents git merge --abort.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How diff3 compares with merge and zdiff3

Style What appears in a conflict Trade-off
merge Current and incoming versions, separated by =======; no base section. Often produces smaller conflict regions, but provides less context about the original text.
diff3 Current and incoming versions plus the common-base text under |||||||. Makes it easier to see how both sides changed the original passage, though conflict blocks can be larger.
zdiff3 Like diff3, with matching lines near the beginning or end of a conflict region removed from the region. Retains base context while trimming some boundary-line bulk.

These styles affect the conflict text Git writes; none determines the correct final content. Git describes their formatting and trade-offs in its merge documentation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When to use a merge tool

You can resolve markers directly in an editor; a separate merge utility is optional. Git’s git mergetool command can launch a configured utility, either for all conflicted files or for selected paths. Git lists tools such as KDiff3 and Meld in its git-mergetool documentation. A tool can present the competing versions visually, but you still need to choose and verify the intended result.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.