My expectation is to have the three files opened in a meld window, then I can look at the changes between branch1/branch2 and then visually make sure the same change is in master. I just realized that I can do this by checking out each file from the three branches independently, then passing the filenames as arguments directly to meld.The checkout can be done as per this SO answer: https://stackoverflow.com/a/888623/350265推荐答案 一线手动命令通过将bash中的<(cmd)语法与git show想法结合在一起,可以在文件的三个版本上调用meld而不使用临时文件:You can invoke meld on three versions of the file without using temporary files by combining the <(cmd) syntax in bash with your git show idea:meld <(git show master:file) <(git show branch1:file) <(git show branch2:file)这将弹出融合文件,分别引用三个分支中的文件dev/fd/61,/dev/fd/62和/dev/fd/63.名称不是很友好,但是您会习惯的.关键是它将显示您想要看到的内容.This will pop up meld with files dev/fd/61, /dev/fd/62 and /dev/fd/63 refering to the file in each of the three branches. The names are not very friendly, but you'll get used to that. The point is that it will show what you want to see. 编写脚本显而易见的下一步是使用脚本简化语法:The obvious next step is to simplify the syntax with a script:创建文件~/bin/git-meld3(或PATH中的其他任何位置):Create file ~/bin/git-meld3 (or anywhere else on your PATH):#!/bin/bashmeld <(git show $1:$4) <(git show $2:$4) <(git show $3:$4)使其可执行:chmod +x ~/bin/git-meld3调用:git meld3 master branch1 branch2 myfilename该命令适用于任何内容:The command works with any committish:git meld3 master 36d1cf756 HEAD^^^ myfilename 更灵活的脚本此~/bin/git-meld脚本接受两个或三个承诺:This ~/bin/git-meld script accepts two or three committishes:#!/bin/bashif [[ $# -eq 3 ]]; then meld <(git show $1:$3) <(git show $2:$3)elif [[ $# -eq 4 ]]; then meld <(git show $1:$4) <(git show $2:$4) <(git show $3:$4)else echo Usage: git meld committish1 committish2 [committish3] file >&2 exit 1fi PS在我自己的机器上,我必须像这样调用Meld:python2.6 /usr/bin/meld,可能是因为未正确安装它,所以这是我的实际~/bin/git-meld3脚本:On my own machine, I have to invoke meld like this: python2.6 /usr/bin/meld, possibly because it's not installed correctly, so this is my actual ~/bin/git-meld3 script:#!/bin/bashpython2.6 /usr/bin/meld <(git show $1:$4) <(git show $2:$4) <(git show $3:$4)产地已老!该脚本说它需要Python 2.4,但是不能用2.7或3编译.所幸,它确实可以用2.6运行,因此我能够测试我的解决方案.Meld is old! the script says it requires Python 2.4, but it fails to compile with 2.7 or 3. Fortunately, it does run with 2.6, so I was able to test my solution. 这篇关于如何使用git做三向图形化差异(不合并)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-04 23:20