无法在 Git 的两个独立分支中比较文件 [英] Unable to diff files in two separate branches in Git
问题描述
我在 branchA 中有 FileA,在 branchB 中有 FileB.
I have FileA in branchA and FileB in branchB.
问题是我一次只能访问一个文件.我希望能够通过 FileMerge 或 meld 比较文件,因为它们是我为 Mac 找到的唯一 diffTools.
The problem is that I can access only one file at time. I would like to be able to compare the files by FileMerge or meld, since they are the only diffTools whichI have found for Mac.
如何通过合并/文件合并两个文件来区分?
[已解决]:第一个问题: FileMerge 不允许标准输入
[Solved]: 1st developed Problem: FileMerge does not allow standard input
Masi:您可以使用 opendiff 来允许FileMerge 从标准输入中获取文件.那么接下来的问题就是如何让git的diff工具使用opendiff.
Masi: You can use opendiff to allow FileMerge to have files from standard input. So the next problem is to find how to make git's diff tool to use opendiff.
第二个开发问题:让 Git 的 diff 工具在 Mac 上使用 opendiff
2nd developed Problem: to make Git's diff tool to use opendiff in Mac
推荐答案
您可以使用git mergetool" 用于合并,在现代 git(意味着 1.6.3 及更高版本)中"git difftool" 用于使用图形工具进行比较.当然,您必须先配置它们,但它们会进行一些自动检测(当然,还有一些硬编码的偏好),如果我没记错的话,内置了 opendiff 支持.
You can use "git mergetool" for merging, and in modern git (meaning version 1.6.3 and later) "git difftool" for comparing using graphical tools. Of course you would have to configure them first, but they do some autodetection (with some hardcoded preference, of course), and if I remember correctly opendiff support is built in.
当然,您可以像使用普通的git diff"一样使用图形工具(opendiff/FileMerge),例如
And then of course you would be able to use your graphical tool (opendiff / FileMerge) as you would use ordinary "git diff", for example
prompt> git difftool somebranch:UNREADME otherbranch:README
这篇关于无法在 Git 的两个独立分支中比较文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!