Tag Archives: visual studio

Using SemanticMerge with Visual Studio tools for Git

Microsoft recently released an updated version of its Visual Studio Tools for Git. These tools allow to create, branch and merge inside Visual Studio. In this article we will see how to configure Semantic Merge Tool as custom merge tool in Visual Studio.

When we create a new project inside Visual Studio and add it to version control, a new repository is created in our local folder. Visual Studio adds its custom diff & merge tool to the repository configuration, so for using Semantic Merge, we need to modify that.

What we need to do is simply edit the file called configuration placed inside our .git folder with our favourite text editor, add the following text (replace USERNAME with your own user):

[mergetool "MergeTool"]
path = C:/Users/{USERNAME}/AppData/Local/PlasticSCM4/semanticmerge/semanticmergetool.exe
cmd = \"C:/Users/{USERNAME}/AppData/Local/PlasticSCM4/semanticmerge/semanticmergetool.exe\" -b=\"$BASE\" -bn=\"$BASE\" -s=\"$REMOTE\" -sn=\"$REMOTE\" -d=\"$LOCAL\" -a -r=\"$MERGED\" -l=csharp -emt=\"\"\"C:/Users/{USERNAME}/AppData/Local/PlasticSCM4/semanticmerge/mergetool.exe\"\" -b=\"\"@basefile\"\" -bn=\"\"@basesymbolic\"\" -s=\"\"@sourcefile\"\" -sn=\"\"@sourcesymbolic\"\" -d=\"\"@destinationfile\"\" -dn=\"\"@destinationsymbolic\"\" -r=\"\"@output\"\" -t=\"\"@filetype\"\" -i=\"\"@comparationmethod\"\" -e=\"\"@fileencoding\"\"\" -edt=\"\"\"C:/Users/{USERNAME}/AppData/Local/PlasticSCM4/semanticmerge/mergetool.exe\"\" -s=\"\"@sourcefile\"\" -sn=\"\"@sourcesymbolic\"\" -d=\"\"@destinationfile\"\" -dn=\"\"@destinationsymbolic\"\" -t=\"\"@filetype\"\" -i=\"\"@comparationmethod\"\" -e=\"\"@fileencoding\"\"\"

And finally replace the default mergetool:

[merge]
tool = vsdiffmerge (before)

[merge]
tool = MergeTool (after)

After these simple steps, when we try to merge a branch and conflicts arise, we will get this window:

Capture

If we click on “Merge” our Semantic Merge tool will launch.

Happy hacking!.

More info at SemanticMerge.com