Unity Smart Merge (UnityYAMLMerge.exe): how to configure vsDiffMerge.exe in the mergespecfile.txt?


I am using GitHub as my repository and I want to use vsDiffMerge.exe as my fallback merge tool. I tried to configure it in mergespecfile.txt as:

* use “C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsdiffmerge.exe” “$LOCAL” “$REMOTE” “$BASE” “$MERGED” //m

and as:

* use “C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsdiffmerge.exe” “%r” “%l” “%b” “%d”

The first command does not work at all. The second command does just the diff (not the merge operation - more information here) and I tried to add the //m in the end, but same thing, it just does the diff.

In SourceTree, I have the UnityYAMLMerge.exe correctly configured:

Merge Tool = Custom

Diff command = C:\Program Files\Unity\Editor\Data\Tools\UnityYAMLMerge.exe

Arguments = merge -p “$BASE” “$REMOTE” “$LOCAL” “$MERGED”

The YAML merge (scene and prefabs) works well, but the problem is to launch the fallback tool for scripts.

By the way, if I configure the vsDiffMerge.exe directly in SourceTree like below it works well for the scripts (but for YAML not of course - I want to use the UnityYAMLMerge.exe for prefabs and scenes as the default merge tool, not vsDiffMerge.exe):

Merge Tool = Custom

Diff command = C:\Program Files (x86)\Microsoft Visual Studio

Arguments = “$LOCAL” “$REMOTE” “$BASE” “$MERGED” //m

Nowadays, I keep switching between those configurations in SourceTree (when I need to merge scripts I put vsDiffMerge.exe, when I need to merge YAML I put UnityYAMLMerge.exe), but this is not productive and the mergespecfile.txt should work.

By the way, I could configured successfully p4Merge in mergespecfile.txt, but I prefer vsDiffMerge.exe :slight_smile:



I created a proxy script as:

o:\git	ools\vsmerge.bat


"c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\vsDiffMerge.exe" /m "%1" "%2" "%3" "%4" 

I am invoking this from mergefilespec.txt:

 * use "o:\git	ools\vsmerge.bat" "%r" "%l" "%b" "%d"

It did not work without the proxy script. This way though the merge button works in the team explorer from VS for code.

I found a solution that worked for me (although I could not correctly configure the mergespecfile.txt file to use vsDiffMerge.exe):

in .gitconfig I added an addition entry:

[mergetool "vs"]
	cmd = 'C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/vsdiffmerge.exe' $LOCAL $REMOTE $BASE $MERGED //m
	trustExitCode = true

And in the console I run:

For .prefab and .unity:

git mergetool

For .cs:

git mergetool --tool=vs

If I need to run for a specific file:

git mergetool --tool=vs *<file_name>.cs

Here is my whole merge/diff configuration in the .gitconfig file:

[mergetool "vs"]
	cmd = 'C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/vsdiffmerge.exe' $LOCAL $REMOTE $BASE $MERGED //m
	trustExitCode = true

[difftool "sourcetree"]
	cmd = 'C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/vsdiffmerge.exe' $LOCAL $REMOTE Source Target //t
[mergetool "sourcetree"]
	cmd = 'C:/Program Files/Unity5.5.1f1/Editor/Data/Tools/UnityYAMLMerge.exe' merge -p $BASE $REMOTE $LOCAL $MERGED
	trustExitCode = false
	keepTemporaries = true
	keepBackup = false

	tool = sourcetree
    	tool = sourcetree
    	autocrlf = true
So, this solved my merge issues with the .cs files (which was my main merge configuration problem). But my fallback tool in the mergespecfile.txt is still p4merge (which does not bother me so much to solve unsolved scene and prefab conflicts the Unity Smart merge could not handle):

    unity use "C:\Program Files\Perforce\p4merge.exe" "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
    prefab use "C:\Program Files\Perforce\p4merge.exe" "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
    # Perforce merge
    * use "%programs%\Perforce\p4merge.exe" "%b" "%l" "%r" "%d"
    * use "%programs%/p4merge.app/Contents/Resources/launchp4merge" "%b" "%l" "%r" "%d"
If anyone knows how to configure the mergespecfile.txt to work with the vsDiffMerge.exe as the fallback tool I would like to see the solution.