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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Gitember: Building a Git Client Beyond Commit, Push, and Pull
  • Closing the Drift Loop: An AI Agent That Drafts Terraform Fixes
  • When a Coding Agent Fixes the Test Instead of the Bug
  • Building a Scope-Constrained AI Agent for Automated CI Failure Repair

Trending

  • Designing for Hot Keys: When Distributed Systems Stop Distributing
  • Beyond the Wall of Charts: How Advanced Observability Displaced the Telemetry Dashboard
  • The Self-Hosting Math Changed While We Were Still Arguing About Sovereignty
  • Understanding Vector Databases: Concepts, Similarity Search, and Trade-offs for Enterprise Applications

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. How to Configure diff and Merge Tool in Visual Studio Git Tools

How to Configure diff and Merge Tool in Visual Studio Git Tools

If you are using Visual Studio plugin for Git, but you have also configured Git with MSys git, probably you could be surprised by some Visual Studio behavior.

By 
Ricci Gian Maria
·
Mar. 20, 13 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
75.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

if you are using  visual studio  plugin for git, but you have also configured git with msys git, probably you could be surprised by some  visual studio  behavior. the most obvious one is that commits are done using the wrong user.name and user.email configuration as i’ve described in  visual studio tools for git, a primer,  other one can be:  tools used to do merge and diff during conflicts  .

suppose you are working with  visual studio  , you issue a pull and find that there is some conflicts in repository.

image

 figure 1:   pull operation has a conflict 

now you should resolve all conflicts before being able to continue work: you can click on file name that is conflicting and you are presented with a ui different from the one you are used with standard  tfs  source control.

image

 figure 2:   ui to manage conflicts when you are using git in  visual studio  

if you press “compare files” to visualize diff of files,  it could happen that kdiff3 is opened to visualize the difference, instead of resolving directly inside visual studio  .

image

 figure 3:   file compare is done with kdiff3 instead of visualizing them inside visual studio 

this happens because visual studio git plugin uses standard git configuration, your local repository probably does not have any specific tools for diff and merge (unless you configured them), so global settings are honored. to verify actual settings you can open a git bash on the repository, issue a  git config –list  command  and look at merge.tool and diff.tool settings 

image

 figure 4:   actual configuration for merge and diff tools 

since i’ve configured kdiff3 as standard conflict resolution tool after i installed msysgit, visual studio honors this settings and opens kdiff3 to do the diff, even if i’m inside the ide of vs. if you prefer using visual studio you should configure vs as diff and merge tools and  you can choose to configure this at repository level or at global level  . to change only a local repository, open .git folder and edit   config   file adding this piece of configuration.

1
      tool = vsdiffmerge
[difftool]
      prompt = true
[difftool "vsdiffmerge"]
      cmd = "c:\program files (x86)\microsoft visual studio 11.0\common7\ide\vsdiffmerge.exe" "$local" "$remote" //t
      keepbackup = false
      trustexistcode = true
[merge]
      tool = vsdiffmerge
[mergetool]
      prompt = true
[mergetool "vsdiffmerge"]
      cmd = "c:\program files (x86)\microsoft visual studio 11.0\common7\ide\vsdiffmerge.exe" "$remote" "$local" "$base" "$merged" //m
      keepbackup = false
      trustexistcode = true

if you want to change global configuration, you should edit a file named .gitconfig usually located inside your profile folder (c:usersyourname).

 you can edit config file with a standard notepad or text editor, it is a simple text configuration file.  once saved, return to visual studio and choose again to compare files,  you should now being able to resolve conflicts directly from visual studio  . if you like this option you can setup visual studio as diff and merge tool in global git configuration, so it will be available for every repository you are working with.

image

 figure 5:   once configured, visual studio is used as a diff tool for git repository 

you can use visual studio not only for diff, but also for merge; press merge button and you will be prompted with a merge ui.

image

 figure 6:   merge tool of visual studio 

once a file is merged, you can press the “accept merge” button in the top left area to resolve conflict and once all conflicts are resolved, you can go to commit pane and commit locally result of merge operations, and everything is done from inside visual studio.

Git Diff

Published at DZone with permission of Ricci Gian Maria. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Gitember: Building a Git Client Beyond Commit, Push, and Pull
  • Closing the Drift Loop: An AI Agent That Drafts Terraform Fixes
  • When a Coding Agent Fixes the Test Instead of the Bug
  • Building a Scope-Constrained AI Agent for Automated CI Failure Repair

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook