在 Git 中使用 Visual Studio 2012 的内置合并工具
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12670148/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using Visual Studio 2012's built-in merge tool with Git
提问by Adam Drewery
So, I don't know if anyone's noticed but the new Merge Tool packaged with VS2012 is sick-o to the max. I've recently moved to Git for my source control and really want to be able to set up VS2012 as my default difftool/mergetool.
所以,我不知道有没有人注意到,但与 VS2012 一起打包的新 Merge Tool 已经病入膏肓了。我最近转移到 Git 进行源代码控制,并且真的希望能够将 VS2012 设置为我的默认 difftool/mergetool。
Any suggestions as to how to do this? I'd rather the diff/merge is started in the active VS2012 window and not a new instance if possible.
关于如何做到这一点的任何建议?如果可能,我宁愿在活动的 VS2012 窗口中启动差异/合并,而不是在新实例中启动。
采纳答案by R0MANARMY
If you are using Git Source Control Providerwith Visual Studio, it looks like this featurewas implemented and is available as of version 1.0.0.
如果您在Visual Studio中使用Git 源代码控制提供程序,则此功能似乎已实现并且从 1.0.0 版开始可用。
Or if you start using Microsoft'stools for git, that will also use the built-in diff tool. From some of the screenshots, it looks like it'll 2-way merge, with the result at the bottom.
或者,如果您开始使用Microsoft 的git 工具,那也将使用内置的 diff 工具。从一些截图来看,它看起来像是 2 路合并,结果在底部。
回答by guanome
This articleexplains how to do this. I tried this out and it works. In my usage, the diff was opened in any existing instance of Visual Studio, which is what you preferred.
这篇文章解释了如何做到这一点。我试过了,它有效。在我的使用中,差异是在 Visual Studio 的任何现有实例中打开的,这是您喜欢的。
[diff]
tool = vsdiffmerge
[difftool]
prompt = false
[difftool "vsdiffmerge"]
cmd = '"C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/vsdiffmerge.exe"' "$LOCAL" "$REMOTE" //t
keepbackup = false
trustexitcode = true
[merge]
tool = vsdiffmerge
[mergetool]
prompt = false
[mergetool "vsdiffmerge"]
cmd = '"C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/vsdiffmerge.exe"' "$REMOTE" "$LOCAL" "$BASE" "$MERGED" //m
keepbackup = false
trustexitcode = true
Or use %VSINSTALLDIR%
to always reference the version of Visual Studio that matches the commandline you have opened (this only works when the Visual Studio environment has been setup, either by using the Visual Studio Command Prompt shortcut or manually calling vsvars32.bat
):
或者用于%VSINSTALLDIR%
始终引用与您打开的命令行匹配的 Visual Studio 版本(这仅在设置了 Visual Studio 环境时有效,通过使用 Visual Studio 命令提示符快捷方式或手动调用vsvars32.bat
):
[diff]
tool = vsdiffmerge
[difftool]
prompt = false
[difftool "vsdiffmerge"]
cmd = '"%VSINSTALLDIR%Common7/IDE/vsdiffmerge.exe"' "$LOCAL" "$REMOTE" //t
keepbackup = false
trustexitcode = true
[merge]
tool = vsdiffmerge
[mergetool]
prompt = false
[mergetool "vsdiffmerge"]
cmd = '"%VSINSTALLDIR%Common7/IDE/vsdiffmerge.exe"' "$LOCAL" "$REMOTE" "$BASE" "$MERGED" //m
keepbackup = false
trustexitcode = true
回答by Küzdi Máté
Te solution marked as answered did not work for me, but this did (I had the vsdiffmerge.exe location in my path - don't know if it had anything to with it):
标记为已回答的解决方案对我不起作用,但这确实有效(我的路径中有 vsdiffmerge.exe 位置 - 不知道它是否与它有关):
[diff]
tool = vsdiffmerge
guitool = vsdiffmerge
[difftool]
prompt = true
[difftool "vsdiffmerge"]
cmd = $LOCAL $REMOTE /t
keepbackup = false
trustexistcode = true
path = C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/vsDiffMerge.exe
[merge]
tool = vsdiffmerge
[mergetool]
prompt = false
[mergetool "vsdiffmerge"]
cmd = $REMOTE $LOCAL $BASE $MERGED /m
keepbackup = false
trustexitcode = true
path = C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/vsDiffMerge.exe