为什么git会将一些cpp文件视为二进制文件?
问题描述:
这里的git log
输出:为什么git会将一些cpp文件视为二进制文件?
* 5a831fdb34f05edd62321d1193a96b8f96486d69 HEAD (HEAD, origin/work, work)
| LIB/xxx.cpp | Bin 592994 -> 593572 bytes
| LIB/xxx.h | 5 +++++
| LIB/bbb/xxx.h | 9 +++++++++
| LIB/aaa/xxx.cpp | Bin 321534 -> 321536 bytes
| LIB/aaa/yyy.cpp | 31 +++++++------------------------
| tests/aaa/xxx.cpp | 29 +++++++++++++++++++++++++++++
| tests/test_xxx.vcproj | 4 ++++
| 7 files changed, 54 insertions(+), 24 deletions(-)
为什么它处理一些文件,二进制,和其他人没有?这给了严重的问题,因为git也不想自动合并它们。因此几乎所有的merge/rebase/pull操作都成为一种痛苦。
这里的回购配置:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://xxx/project.git
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "work"]
remote = origin
merge = refs/heads/work
[svn-remote "svn"]
url = xxxx
fetch = :refs/remotes/git-svn
也core.autocrlf =在主要的.gitconfig假。
编辑 我设置core.autocrlf为true的意见建议,但这似乎并没有影响到下一个合并后的我(也许是太晚了,现在改autocrlf?还是无关的问题):
> git merge work
warning: Cannot merge binary files: LIB/xxx.cpp (HEAD vs. work)
warning: Cannot merge binary files: LIB/aaa/xxx.cpp (HEAD vs. work)
Auto-merging LIB/xxx.cpp
CONFLICT (content): Merge conflict in LLIB/xxx.cpp
Auto-merging LIB/xxx.h
Auto-merging LIB/aaa/xxx.cpp
CONFLICT (content): Merge conflict in LIB/aaa/xxx.cpp
Automatic merge failed; fix conflicts and then commit the result.
而且现在控释坚持在几个文件的改变lineendings(这是我做什么不想要的)。
解决方案
我结束了这个在文件的属性,这要归功于:
需要的-text
部分保留从混帐转换lineends,即使core.autocrlf设置假。
那么为什么`core.autocrlf = false`? – ulidtko 2011-01-19 13:22:17
这是我的理解,这使得git根本不会转换任何行结束符,即让我看到这些文件,因为它是我所追求的。这是不正确的? – stijn 2011-01-19 13:31:35