我已经阅读了 Git Pro 网站,并且在 StackOverflow 上阅读了多个答案,但遗憾的是我根本无法让 .gitattributes 为我工作。
每当我使用git difftool
时,它都会尝试显示二进制文件之间的差异,例如图像文件 (PNG)。
我在我的 .gitattributes 文件中尝试了多种组合,但是每当我运行我的git difftool
命令时,它仍然会尝试比较二进制文件。
在我的存储库的文件夹中,我有:
.git
.gitattributes
[我的项目的文件子目录]
我为我的 .gitattributes 文件尝试了许多过滤器组合。例如:
*.pbxproj 二进制
*.png 二进制
或者还有:
*.pbxproj 二进制 -diff
*.png 二进制 -diff
甚至:
*.pbxproj 二进制
*.png 二进制
*.pbxproj -diff -difftool
*.png -diff -difftool
每次,我只需将我的 .gitattributes 文件添加到索引中并提交它。但是,这样做之后,当我运行 mygit difftool
检查两个分支之间的差异时,会发生这种情况:
git difftool otherBranch HEAD
查看:“MyApp.xcodeproj/project.pbxproj”点击返回以启动“diffmerge”:
查看:“MyApp/Background1.png”点击返回以启动“diffmerge”:
它怎么会这样?如何最终正确设置我的 .gitattributes 文件,这样我就不必查看这些特定文件的差异?
为了进一步调查,我使用了git check-attr
如下命令:
git check-attr binary MyApp/MainBackground.png
输出是MyApp/MainBackground.png: binary: set
......我想知道为什么 git difftool 仍然强迫我查看差异!