How to configure visual studio 2017 to use external difftool and mergetool

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.