Git忽略autocrlf配置标志

时间:2016-10-19 07:52:44

标签: git newline gitattributes core.autocrlf

我正在尝试为源文件具有CRLF行结尾的git项目做贡献。克隆项目时,git会立即将所有源文件标记为已修改。我的配置是:

$ git config --list
push.default=simple
user.email=xxxx.xxxx@xxxx.xxx
user.name=xxxx
merge.defaulttoupstream=true
merge.tool=kdiff3
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.autocrlf=false
remote.origin.url=xxxx.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

如上所示,autocrlf设置为false,应该告诉git忽略行结尾。

该项目有一个.gitattributes文件,如下所示:

# Sources
*.c   text eol=crlf
*.cc  text eol=crlf
*.cxx text eol=crlf
*.cpp text eol=crlf
*.CPP text eol=crlf
*.c++ text eol=crlf
*.hpp text eol=crlf
*.HPP text eol=crlf
*.h   text eol=crlf
*.H   text eol=crlf
*.h++ text eol=crlf
*.hh  text eol=crlf

# Project files
*.sln     text eol=crlf
*.sdf     binary
*.opensdf binary
*.suo     binary
*.vcxproj         text eol=crlf
*.vcxproj.filters text eol=crlf
*.vcxproj.user    text eol=crlf

# Compiled Object files
*.slo binary
*.lo binary
*.o binary
*.obj binary

# Precompiled Headers
*.gch binary
*.pch binary

# Compiled Dynamic libraries
*.so binary
*.dylib binary
*.dll binary

# Compiled Static libraries
*.lai binary
*.la binary
*.a binary
*.lib binary

# Executables
*.exe binary
*.out binary
*.app binary

克隆项目后,文件确实有CRLF行结尾:

$ file src/charbuf.cpp 
src/charbuf.cpp: C source, Non-ISO extended-ASCII text, with CRLF line terminators

为什么git仍然将它们标记为已修改?

0 个答案:

没有答案