DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. DevOps and CI/CD
  4. Using SourceGear DiffMerge With TFS in Visual Studio and Git

Using SourceGear DiffMerge With TFS in Visual Studio and Git

This article shows you how to configure TFS and Git to use SourceGear DiffMerge.

$$anonymous$$ user avatar by
$$anonymous$$
·
May. 13, 19 · Tutorial
Like (2)
Save
Tweet
Share
4.72K Views

Join the DZone community and get the full member experience.

Join For Free

This post isn't to advocate DiffMerge over another file comparer, but an explanation on how to set up DiffMerge with either TFS in Visual Studio or Git.

I've been using DiffMerge since VS2010, so pretty much forever as far as I am concerned. Back then there was no built-in diff viewer in Visual Studio so you had to use a third-party tool. Because I've used it for so long I'm quite reluctant to change. Looking at differences in files is something every developer does often, whether it is local code changes or a code review for another member of the team. It has to be a quick and efficient process. That's why I stick with DiffMerge. I know it works, I know how to use it, I'm familiar with the layout, and I can quickly navigate and scan the document.

These are the settings I use and an explanation on the flags and arguments.

Configuring DiffMerge With TFS in Visual Studio

From the Visual Studio toolbar select: Tools -> Options -> Source Control

Make sure Current source control plug-in: has Visual Studio Team Foundation Server selected.

Visual Studio and DIffMerge

Visual Studio and DiffMerge

Then select Visual Studio Team Foundation Server -> Configure User Tools... and add settings for compare and merge.

Visual Studio and DIffMerge

Visual Studio and DiffMerge

Compare Settings

Extension: .*

Command: C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe

Arguments: /title1=%6 /title2=%7 %1 %2

Merge Settings

Extension: .*

Command: C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe

Arguments: /m /title1=%6 /title2=%7 /title3=%8 /c=%9 %1 %3 %2 /r=%4

Compare Argument Parameters

The compare argument parameters and their meaning:

  • %1 = Original file, the pre-changes file
  • %2 = Modified file (in diff, the post-changes file)
  • %6 = Original file label (The label for the %1 file)
  • %7 = Modified file label (The label for the %2 file)

Merge Flags and Argument Parameters

The merge flags and their meaning:

  • /m = Runs Auto-Merge immediately after loading the files.
  • /title1 = Sets the File Panel Label for the first file/column.
  • /title2 = Sets the File Panel Label for the second file/column.
  • /title3 = Sets the File Panel Label for the third file/column.
  • /c = A caption for the application title bar of the first window
  • /r = Specifies a pathname for saving the merge result. If no pathname is specified then if saved the center file will be overwritten.

The merge argument parameters and their meaning:

  • %1 = Original file, the "server" or "theirs" file, the file that is the base file after "their" changes were applied.
  • %2 = Modified file, the "yours" file - the base file with "your" changes applied.
  • %3 = Base file (in the 3-way merge operation, the file which both "theirs" and "yours" are derived from - the common ancestor. This doesn't mean it's the version the changes were based from, since this may be a cherry-pick merge).
  • %4 = Merged file (The output file for the merge operation - the filename that the merge tool should write to).
  • %6 = Original file label (The label for the %1 file).
  • %7 = Modified file label (The label for the %2 file).
  • %8 = Base file label (The label for the %3 file).
  • %9 = Merged file label (The label for the %4 file).

Reference links and recommended reading:

  • diff/merge configuration in Team Foundation - common Command and Argument values

  • Integration with Microsoft TFS

Using DiffMerge With Git

DiffMerge can also be used with Git version control. The following lines must be added to .gitconfig file.

[diff]
    tool = DiffMerge
[difftool "DiffMerge"]
    cmd = 'C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe' "$LOCAL" "$REMOTE"
[merge]
    tool = DiffMerge
[mergetool "DiffMerge"]
    cmd = 'C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe' -merge -result="$PWD/$MERGED" "$PWD/$LOCAL" "$PWD/$BASE" "$PWD/$REMOTE"
trustExitCode = true
[mergetool]
    keepBackup = false

Compare

The compare argument parameters:

  • $LOCAL = The original file.
  • $REMOTE = The modified file.

Using the order above, the original file will appear on the left and the modified on the right.

Merge

The merge flags:

  • merge = auto merge.
  • result = save file.

The merge argument parameters:

  • $MERGED = merged file
  • $LOCAL = the original file
  • $BASE = the Base file
  • $REMOTE = the modified file

Reference links and recommended reading.

Integration with GitHub for Windows or Git Bash Shell

source control Git Label

Published at DZone with permission of $$anonymous$$, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Cloud Performance Engineering
  • A Beginner’s Guide To Styling CSS Forms
  • Java REST API Frameworks
  • gRPC on the Client Side

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: