我在Cygwin上尝试了msysGit和Git。两者本身都工作得很好,并且都能完美地运行gitk和git-gui。
现在我该如何配置合并工具呢?(Vimdiff在Cygwin上工作,但我更希望能有一个对我们一些喜欢windows的同事更友好的东西。)
我在Cygwin上尝试了msysGit和Git。两者本身都工作得很好,并且都能完美地运行gitk和git-gui。
现在我该如何配置合并工具呢?(Vimdiff在Cygwin上工作,但我更希望能有一个对我们一些喜欢windows的同事更友好的东西。)
当前回答
我用一个叫WinMerge的应用程序(http://winmerge.org/) 他们手册中的信息(http://manual.winmerge.org/CommandLine.html)
这是我通过.gitconfig从mergetool指令中使用的bash脚本
#!/bin/sh
# using winmerge with git
# replaces unix style null files with a newly created empty windows temp file
file1=$1
if [ "$file1" == '/dev/null' ] || [ "$file1" == '\\.\nul' ] || [ ! -e "$file1" ]
then
file1="/tmp/gitnull"
`echo "">$file1`
fi
file2=$2
if [ "$file2" == '/dev/null' ] || [ "$file2" == '\\.\nul' ] || [ ! -e "$file2" ]
then
file2="/tmp/gitnull"
`echo "">$file2`
fi
echo diff : $1 -- $2
"C:\Program files (x86)\WinMerge\WinMergeU.exe" -e -ub -dl "Base" -dr "Mine" "$file1" "$file2"
基本上,bash会在一个空文件中处理diff的结果,并在正确的位置创建一个新的临时文件。
其他回答
呸,这终于为我工作(Windows 7 + Cygwin + TortoiseMerge):
在. /配置:
cmd = TortoiseMerge.exe /base:$(cygpath -d \"$BASE\") /theirs:$(cygpath -d \"$REMOTE\") /mine:$(cygpath -d \"$LOCAL\") /merged:$(cygpath -d \"$MERGED\")
感谢之前的海报为提示使用cygpath!
我在WinXP上使用Portable Git(工作很好!),需要解决分支中出现的冲突。在我检查的所有gui中,KDiff3被证明是使用起来最透明的。
但是我在这篇博文中找到了让它在Windows中工作所需的说明,这些说明与这里列出的其他方法略有不同。它基本上相当于把这些行添加到我的.gitconfig文件中:
[merge]
tool = kdiff3
[mergetool "kdiff3"]
path = C:/YourPathToBinaryHere/KDiff3/kdiff3.exe
keepBackup = false
trustExitCode = 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 config --global merge.tool p4mergetool
git config --global mergetool.p4merge.cmd 'p4merge $BASE $LOCAL $REMOTE $MERGED'
git config --global mergetool.p4mergetool.trustExitCode false
git config --global mergetool.keepBackup false
另外,我也不知道为什么,但是米兰·加迪安的回答把我搞砸了。
如果你通过cygwin来做这件事,你可能需要使用cygpath:
git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd 'p4merge `cygpath -w $BASE` `cygpath -w $LOCAL` `cygpath -w $REMOTE` `cygpath -w $MERGED`'