9

I configured DiffMerge for difftool and mergetool in git global configuration. I read that Visual Studio honors this settings of global git configuration. Here is my git config:

git config  --global --list
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
mergetool.DiffMerge.trustexitcode=true
user.name=masiboo
user.email=masiboo@gmail.com

But if try to see diff from visual studio, it opens vs own diff tool. How can I open or configure to open external tool?

Jan Schultke
  • 17,446
  • 6
  • 47
  • 96
masiboo
  • 4,537
  • 9
  • 75
  • 136

2 Answers2

9

Took me a while also.

It seems that visual studio 2017 "helps" you , and if something is wrong it just launches the visual studio diff.

Here is my working .gitconfig settings :

[diff]
    tool = winmerge

[difftool "winmerge"]  
  trustExitCode = true
  cmd = \"C:\\Program Files (x86)\\WinMerge\\WinMergeU.exe\" -u -e \"$LOCAL\" \"$REMOTE\"

Do note that visual studio seems to insert a repository level config with diff tools settings , in that case you need to clear the .git/config settings on your repository.

Hagay Goshen
  • 599
  • 2
  • 13
  • Thanks for this. I use Sourcetree and GitExtensions, and they seem to screw this setting up during initial setup. My [diff] section, which I think I initially configured using GitExtensions, ended up with only a guitool entry, not a tool entry. And Visual Studio then silently "helped" me by ignoring it all and launching its own diff. – rrreee Jul 19 '18 at 15:10
  • There is no ".gitconfig" file (as you state in your upvoted? answer) for Visual Studio 2017--if you feel there is then please post here exactly where that file is located. – Jazimov Aug 11 '19 at 15:53
  • The .gitconfig file is normally located on c:\users\%username% folder (when %username% is your windows username) – Hagay Goshen Aug 15 '19 at 12:17
1

to use VS code as diff tool i add this to my local git config file, works in VS2019.

[diff]
    tool = vscode
[difftool "vscode"]
    cmd = "code --wait --diff \"$LOCAL\" \"$REMOTE\" "