本文介绍了是否可以使用winmerge查看cygwin的git diff?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我喜欢在cygwin使用git,但是我唯一的缺点是当我想 git difftool 我不能使用任何有用的。 git diff 对我来说很好,但有时候我想使用winmerge通过 git difftool 对于cygwin,SO问题如何在cygwin下配置Mercurial使用WinMerge进行合并? 可以应用于git(当将以下winmerge脚本与旧问题在Git中使用Winmerge文件diff ) #!/ bin / sh / cygdrive / c / Program Files / WinMerge / WinMergeU.EXE/ e / ub / dl other / dr local`cygpath -aw $ 1``cygpath -aw $ 2``cygpath -aw $ 3` 处理 您在本文中有更多详情 Git + WinMerge + Cygwin (来自 Thiru Thirunavukarasu ): (但我仍然推荐上面的 WinMergeU.exe 选项) 将以下行添加到.gitconfig文件中: [diff] tool = winmerge [difftoolwinmerge] cmd = git-difftool-winmerge-wrapper.sh \$ LOCAL\\$ REMOTE\\ \\ [difftool] prompt = false 最后一个选项( prompt = false )是可选的。 创建一个名为 的文件git-difftool-winmerge -wrapper.sh ,并将其放在路径中。 我刚把它放在我的主目录中。您可以通过修改.bash_profile文件(也在您的主目录中)并添加 PATH = $ {PATH}:$ {HOME}来更改默认Cygwin路径以包括主目录 将以下内容添加到 git-difftool-winmerge-wrapper.sh : #!/ bin / sh echo启动WinMergeU.exe \$(cygpath -aw $ 1)\\$(cygpath -aw$ 2)\ if [-f$ 1-a -f$ 2] then C:/ Program Files(x86)/WinMerge/WinMergeU.exe-e -u -wl -dlBase-drMine$(cygpath -aw$ 1)$(cygpath -aw $ 2) else echo跳过一个文件不存在 fi (再次使用这些WinMerge选项进行测试) 脚本 如果你想要使用all WinMerge,对于diff和合并git函数,你有 gist page to follow from ecerulm(Ruben Laguna): diffmerge-diff.sh #!/ bin / sh #在Cygwin中使用SourceGear DiffMerge作为git的mergetool。 #git config --global mergetool.diffmerge.cmddiffmergetool.sh \\ $ LOCAL \\\ $ REMOTE \\\ $ BASE\ \\$\\ $ MERGED \#git config --global mergetool.diffmerge.trustExitCode false #git difftool -t diffmerge branch1..branch2 #参考:http://www.tldp.org/LDP/abs/abs-guide.pdf library = githelperfunctions.sh #[-f $ library]& & 。 $ library 。 $ library echo启动DiffMerge.exe - diffmerge-diff.sh: set_path_vars$ 1$ 2$ 3$ 4 $ b b echo$ diffmergewinpath-t1 = FROM_VERSION -t2 = TO_VERSION --caption = $ caption $ localwinpath $ remotewinpath $ diffmergewinpath-t1 = FROM_VERSION -t2 = TO_VERSION --caption =$ caption$ localwinpath$ remotewinpath diffmerge- merge.sh #!/ bin / sh #在cygwin中使用SourceGear DiffMerge作为git的mergetool。 #git config --global mergetool.diffmerge.cmddiffmergetool.sh \\ $ LOCAL \\\ $ REMOTE \\\ $ BASE\ \\$\\ $ MERGED \#git config --global mergetool.diffmerge.trustExitCode false #git mergetool -t diffmerge #参考:http: /www.tldp.org/LDP/abs/abs-guide.pdf library = githelperfunctions.sh #[-f $ library]&& 。 $ library 。 $ library echo启动DiffMerge.exe - diffmerge-merge.sh: set_path_vars$ 1$ 2$ 3$ 4 $ b b$ diffmergewinpath--merge -t1 = FROM_VERSION -t2 = MERGED -t3 = TO_VERSION --result =$ mergedwinpath--caption =$ caption$ localwinpath$ basewinpath$ remotewinpath unix2dos$ merged githelperfunctions.sh #辅助功能 convert_path(){ file = $ 1 if [$ file=='/ dev / null'] || [! -e$ file] then file =/ tmp / nulla`echo> $ file` fi echo`cygpath - w -a$ file`} set_path_vars(){ local = $ 1 remote = $ 2 base = $ 3 merged = $ 4 echo ========= Cygwin路径======= echoLOCAL:$ local echo REMOTE:$ remote echoBASE:$ base echoMERGED:$ merged localwinpath = $(convert_path$ local) remotewinpath = $(convert_path$ remote) basewinpath = $(convert_path$ base) mergedwinpath = $(convert_path$ merged) echo === ======赢路径======= echoLOCAL:$ localwinpath echoREMOTE:$ remotewinpath echoBASE:$ basewinpath echoMERGED:$ mergedwinpath caption =`basename'$ merged` diffmergewinpath =C:/ Program Files / SourceGear / DiffMerge / DiffMerge.exe winmergewinpath =C:/ Program Files / WinMerge / WinMergeU.exe#diffmergewinpath =`cygpath -u C:/ Program Files / SourceGear / DiffMerge / DiffMerge.exe`#winmergewinpath =`cygpath -u \C:\Program Files\WinMerge\WinMergeU.exe\`} winmerge-diff.sh #!/ bin / sh #在cygwin中使用winmerge作为git的mergetool。 #git config --global difftool.winmerge.cmdwinmerge-diff.sh \\ $ LOCAL \\\ $ REMOTE \\\ $ BASE\ #git config --global mergetool.winmerge.trustExitCode false #git difftool -t winmerge branch1..branch2 #参考:http://www.tldp .org / LDP / abs / abs-guide.pdf #参考:http://winmerge.org/docs/manual/CommandLine.html library = githelperfunctions。 sh #[-f $ library]&& 。 $ library 。 $ library echo启动winmerge.exe - winmerge-diff.sh: set_path_vars$ 1$ 2$ 3$ 4 $ b b$ winmergewinpath/ dlLOCAL。$ caption/ drTO_VERSION。$ caption$ localwinpath$ remotewinpath winmerge-merge.sh b $ b #!/ bin / sh #在cygwin中使用winmerge作为git的mergetool。 #git config --global mergetool.winmerge.cmdwinmerge-merge.sh \\ $ LOCAL \\\ $ REMOTE \\\ $ BASE\ \\ $ MERGED\#git config --global mergetool.winmerge.trustExitCode false #git mergetool -t diffmerge #参考:http ://www.tldp.org/LDP/abs/abs-guide.pdf #参考:http://winmerge.org/docs/manual/CommandLine.html library = githelperfunctions.sh #[-f $ library]&& 。 $ library 。 $ library echo启动winmerge.exe - winmerge-merge.sh: set_path_vars$ 1$ 2$ 3$ 4$ b b # - 使用WinMergeU conflictFile $ winmergewinpath$ mergedwinpath I like to use git on cygwin, but the only downside I have is when I want to git difftool I cannot use anything useful. git diff is fine for me most of the time, but sometimes I'd like to use winmerge to view these diffs via git difftool is there some way to set this up? 解决方案 For cygwin, the SO question "How can I configure Mercurial to use WinMerge for merges, under cygwin?" can be applied to git (when combining the following winmerge script with the older question "use Winmerge inside of Git to file diff")#!/bin/sh"/cygdrive/c/Program Files/WinMerge/WinMergeU.EXE" /e /ub /dl other /dr local `cygpath -aw $1` `cygpath -aw $2` `cygpath -aw $3`ProcessYou have more details in this article "Git + WinMerge + Cygwin" (from Thiru Thirunavukarasu):(but I would still recommend the WinMergeU.exe options from above) Add the following lines to your .gitconfig file: [diff] tool = winmerge [difftool "winmerge"] cmd = git-difftool-winmerge-wrapper.sh \"$LOCAL\" \"$REMOTE\" [difftool] prompt = false The last option (prompt = false) is optional. You can omit it if you do want Git to prompt you before opening each diff. Create a file named git-difftool-winmerge-wrapper.sh and place it in your path. I just dropped it in my home directory. You can change the default Cygwin path to include your home directory by modifying the .bash_profile file (also in your home directory) and adding PATH=${PATH}:${HOME} Add the following to git-difftool-winmerge-wrapper.sh: #!/bin/sh echo "Launching WinMergeU.exe \"$(cygpath -aw "$1")\" \"$(cygpath -aw "$2")\"" if [ -f "$1" -a -f "$2" ] then "C:/Program Files (x86)/WinMerge/WinMergeU.exe" -e -u -wl -dl "Base" -dr "Mine" "$(cygpath -aw "$1")" "$(cygpath -aw "$2")" else echo "skipping as one file doesn't exist" fi(again, do some testing with those WinMerge options)ScriptsIf you want to go "all WinMerge", both for diff and merge git functions, you have this gist page to follow from ecerulm (Ruben Laguna): diffmerge-diff.sh#!/bin/sh# Use SourceGear DiffMerge as mergetool for git in cygwin.# git config --global mergetool.diffmerge.cmd "diffmergetool.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""# git config --global mergetool.diffmerge.trustExitCode false# git difftool -t diffmerge branch1..branch2# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdflibrary=githelperfunctions.sh#[ -f $library ] && . $library. $libraryecho Launching DiffMerge.exe - diffmerge-diff.sh: set_path_vars "$1" "$2" "$3" "$4"echo "$diffmergewinpath" -t1=FROM_VERSION -t2=TO_VERSION --caption=$caption $localwinpath $remotewinpath"$diffmergewinpath" -t1=FROM_VERSION -t2=TO_VERSION --caption="$caption" "$localwinpath" "$remotewinpath" diffmerge-merge.sh#!/bin/sh# Use SourceGear DiffMerge as mergetool for git in cygwin.# git config --global mergetool.diffmerge.cmd "diffmergetool.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""# git config --global mergetool.diffmerge.trustExitCode false# git mergetool -t diffmerge# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdflibrary=githelperfunctions.sh#[ -f $library ] && . $library. $libraryecho Launching DiffMerge.exe - diffmerge-merge.sh: set_path_vars "$1" "$2" "$3" "$4""$diffmergewinpath" --merge -t1=FROM_VERSION -t2=MERGED -t3=TO_VERSION --result="$mergedwinpath" --caption="$caption" "$localwinpath" "$basewinpath" "$remotewinpath"unix2dos "$merged" githelperfunctions.sh# Helper functionsconvert_path () { file=$1 if [ "$file" == '/dev/null' ] || [ ! -e "$file" ] then file="/tmp/nulla" `echo "">$file` fi echo `cygpath -w -a "$file"`}set_path_vars () { local=$1 remote=$2 base=$3 merged=$4 echo ========= Cygwin paths ======= echo "LOCAL : $local" echo "REMOTE : $remote" echo "BASE : $base" echo "MERGED : $merged" localwinpath=$(convert_path "$local") remotewinpath=$(convert_path "$remote") basewinpath=$(convert_path "$base") mergedwinpath=$(convert_path "$merged") echo ========= Win paths ======= echo "LOCAL : $localwinpath" echo "REMOTE : $remotewinpath" echo "BASE : $basewinpath" echo "MERGED : $mergedwinpath" caption=`basename "$merged"` diffmergewinpath="C:/Program Files/SourceGear/DiffMerge/DiffMerge.exe" winmergewinpath="C:/Program Files/WinMerge/WinMergeU.exe"# diffmergewinpath=`cygpath -u C:/Program Files/SourceGear/DiffMerge/DiffMerge.exe`# winmergewinpath=`cygpath -u \"C:\Program Files\WinMerge\WinMergeU.exe\"`} winmerge-diff.sh#!/bin/sh# Use winmerge as mergetool for git in cygwin.# git config --global difftool.winmerge.cmd "winmerge-diff.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\""# git config --global mergetool.winmerge.trustExitCode false# git difftool -t winmerge branch1..branch2 # Reference: http://www.tldp.org/LDP/abs/abs-guide.pdf# Reference: http://winmerge.org/docs/manual/CommandLine.htmllibrary=githelperfunctions.sh#[ -f $library ] && . $library. $libraryecho Launching winmerge.exe - winmerge-diff.sh: set_path_vars "$1" "$2" "$3" "$4""$winmergewinpath" /dl "LOCAL.$caption" /dr "TO_VERSION.$caption" "$localwinpath" "$remotewinpath" winmerge-merge.sh#!/bin/sh# Use winmerge as mergetool for git in cygwin.# git config --global mergetool.winmerge.cmd "winmerge-merge.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""# git config --global mergetool.winmerge.trustExitCode false# git mergetool -t diffmerge# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdf# Reference: http://winmerge.org/docs/manual/CommandLine.htmllibrary=githelperfunctions.sh#[ -f $library ] && . $library. $libraryecho Launching winmerge.exe - winmerge-merge.sh: set_path_vars "$1" "$2" "$3" "$4"# -- use WinMergeU conflictFile"$winmergewinpath" "$mergedwinpath" 这篇关于是否可以使用winmerge查看cygwin的git diff?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-11 05:31