我在Cygwin上尝试了msysGit和Git。两者本身都工作得很好,并且都能完美地运行gitk和git-gui。

现在我该如何配置合并工具呢?(Vimdiff在Cygwin上工作,但我更希望能有一个对我们一些喜欢windows的同事更友好的东西。)


当前回答

在Cygwin的指导下,唯一对我有用的是:

git config --global merge.tool myp4merge
git config --global mergetool.myp4merge.cmd 'p4merge.exe "$(cygpath -wla $BASE)" "$(cygpath -wla $LOCAL)" "$(cygpath -wla $REMOTE)" "$(cygpath -wla $MERGED)"'
git config --global diff.tool myp4diff
git config --global difftool.myp4diff.cmd 'p4merge.exe "$(cygpath -wla $LOCAL)" "$(cygpath -wla $REMOTE)"'

另外,我喜欢关闭difftool的提示信息:

git config --global difftool.prompt false

其他回答

设置mergetool.p4merge。cmd将不再工作,因为Git已经开始尝试支持p4merge,请参阅libexec/ Git -core/ Git -mergetool——lib。所以我们只需要为git指定mergetool路径,例如p4merge:

git config --global mergetool.p4merge.path 'C:\Program Files\Perforce\p4merge.exe'
git config --global merge.tool p4merge

那么它就会起作用。

Git mergetool是完全可配置的,所以你可以选择你最喜欢的工具。

完整的文档在这里:http://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html

简而言之,您可以通过设置用户配置变量merge.tool来设置默认的合并工具。

如果合并工具是本地支持的工具之一,你只需要设置mergetool.<tool>。工具完整路径的路径(将<tool>替换为您已配置的merge. conf。成为工具。

否则,可以设置mergetool.<tool>。在运行时将shell变量$BASE, $LOCAL, $REMOTE, $MERGED设置为适当的文件。无论你是直接编辑配置文件还是用git config命令设置变量,你都必须小心转义。

像这样的东西应该能让你知道你能做什么('mymerge'是一个虚构的工具)。

git config merge.tool mymerge
git config merge.mymerge.cmd 'mymerge.exe --base "$BASE" "$LOCAL" "$REMOTE" -o "$MERGED"'

一旦你安装了你最喜欢的合并工具,当你有冲突需要解决时,运行git mergetool就很简单了。

来自Perforce的p4merge工具是一个非常好的独立合并工具。

在Windows 7上无以伦比

git config --global merge.tool bc3
git config --global mergetool.bc3.path "C:\Program Files (x86)\Beyond Compare 3\BCompare.exe"

如果有人想在TortoiseGit上使用gvim作为他们的差异工具,那么你需要在文本输入中输入外部差异工具的路径:

path\to\gvim.exe -f -d -c "wincmd R" -c "wincmd R" -c "wincmd h" -c "wincmd J"

我找到了两种方法来配置“SourceGear DiffMerge”作为difftool和github Windows中的mergetool。

命令提示符窗口中的以下命令将更新你的.gitconfig以配置GIT使用DiffMerge:

git config --global diff.tool diffmerge
git config --global difftool.diffmerge.cmd 'C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe  \"$LOCAL\" \"$REMOTE\"'

git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmd  'C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe  -merge  -result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"'

[OR]

将以下行添加到.gitconfig中。这个文件应该在你的主目录C:\Users\UserName:

[diff]
    tool = diffmerge
[difftool "diffmerge"]
    cmd = C:/Program\\ Files/SourceGear/Common/DiffMerge/sgdm.exe \"$LOCAL\" \"$REMOTE\"

[merge]
    tool = diffmerge
[mergetool "diffmerge"]
    trustExitCode = true
    cmd = C:/Program\\ Files/SourceGear/Common/DiffMerge/sgdm.exe -merge -result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"