The instructions below are for Visual Studio 2017 Community Edition. Substitute Professional or Enterprise as needed.

[difftool "vstudio"]
  cmd = 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/vsDiffMerge.exe' $LOCAL $REMOTE Source Target //t
[mergetool "vstudio"]
  cmd = 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/vsDiffMerge.exe' $LOCAL $REMOTE $BASE $MERGED //m
  trustedExitCode = true


# To use as default
[diff]
	tool = vstudio
[merge]
	tool = vstudio
	conflictstyle = diff3
[mergetool]
	keepBackup = false

Command line use:

git mergetool
git difftool

git mergetool --tool=vstudio
git difftool --tool-vstudio

Variables, prefixed with $, are specifying file paths. Note they are enclosed in quote marks, so that spaces in file paths won’t break the command. Source and Target are just labels Visual Studio will use for the files . The /t flag will open the diff in a temporary tab instead of a persisted tab. The /mflag denotes it is a merge in contrast to diff.