How to configure visual studio 2017 to use external difftool and mergetool
Asked Answered
B

2

10

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
[email protected]

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?

Bleachers answered 15/10, 2017 at 9:50 Comment(0)
B
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.

Bethune answered 29/11, 2017 at 12:10 Comment(3)
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.Loyalist
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.Whitehouse
The .gitconfig file is normally located on c:\users\%username% folder (when %username% is your windows username)Bethune
P
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\" "
Paraffinic answered 22/4, 2019 at 5:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.