How to use an external diff tool for Git in Visual Studio 2013?

后端 未结 2 1714
日久生厌
日久生厌 2021-02-10 02:23

I\'ve found this post that explains how you can have Visual Studio 2013 use the built-in diff tool when comparing files in Git, but I\'m having the opposite problem. Right now w

2条回答
  •  囚心锁ツ
    2021-02-10 03:10

    I have had the same issue recently in Visual Studio 2012. I will post the solution here as this is the first thread I found when searching.

    My .gitconfig file looked like this:

    [merge]
        tool = kdiff3
    [diff]
        tool = kdiff3
    [difftool]
        prompt = true
    
    [difftool "kdiff3"]
        path = "C:/Program Files/KDiff3/kdiff3.exe"
        keepBackup = false
        trustExitCode = true
    [mergetool]
        prompt = true
    
    [mergetool "kdiff3"]
        cmd = "C:/Program Files/KDiff3/kdiff3.exe" $BASE $LOCAL $REMOTE -o $MERGED
        keepBackup = false
        trustExitCode = true
    
    [mergetool "vsdiffmerge"]
        cmd = "C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/vsdiffmerge.exe" /m $REMOTE $LOCAL $BASE $MERGED
        keepbackup = false
        trustexistcode = true
    

    The problem was the newlines between config sections.

    Changing the file to this worked correctly:

    [merge]
        tool = kdiff3
    [diff]
        tool = kdiff3
    [difftool]
        prompt = true
    [difftool "kdiff3"]
        path = "C:/Program Files/KDiff3/kdiff3.exe"
        keepBackup = false
        trustExitCode = true
    [mergetool]
        prompt = true
    [mergetool "kdiff3"]
        cmd = "C:/Program Files/KDiff3/kdiff3.exe" $BASE $LOCAL $REMOTE -o $MERGED
        keepBackup = false
        trustExitCode = true
    [mergetool "vsdiffmerge"]
        cmd = "C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/vsdiffmerge.exe" /m $REMOTE $LOCAL $BASE $MERGED
        keepbackup = false
        trustexistcode = true
    

提交回复
热议问题