在 Windows 中覆盖 .gitattributes text=auto
Override .gitattributes text=auto in Windows
这很不直观:
C:\python-tdl\examples\termbox>git config core.autocrlf
false
C:\python-tdl\examples\termbox>git commit termbox.py
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
Aborting commit due to empty commit message.
根据各种媒体 core.autocrlf=false
应该根本没有换行符转换。
在项目根目录中,我发现 .gitattributes
行:
# Auto detect text files and perform LF normalization
* text=auto
如果我评论它,警告就会消失。问题 - 如何自动覆盖此 .gitattibutes
设置?
.gitattributes
覆盖所有配置设置,所以它真的不能被覆盖;可以说是"overrider,"。虽然您可以简单地删除该行,但这将导致其他开发人员的机器出现不一致的行为(如果他们有 core.autocrlf=true
)。所以最好的办法是将以下行添加到 .gitattributes
:* -text
。这将禁用所有文件的 CRLF 处理。
至少在 git 的现代版本中,.git/info/attributes
(或 $GIT_DIR/info/attributes
)会覆盖 .gitattributes
以进行本地配置。
使用* !text
使用core.autocrlf
的值,或* -text
强制不转换。
请参阅 gitattributes
and the text
attribute 的文档。
另请注意: core.eol
, the eol
attribute
这很不直观:
C:\python-tdl\examples\termbox>git config core.autocrlf
false
C:\python-tdl\examples\termbox>git commit termbox.py
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
Aborting commit due to empty commit message.
根据各种媒体 core.autocrlf=false
应该根本没有换行符转换。
在项目根目录中,我发现 .gitattributes
行:
# Auto detect text files and perform LF normalization
* text=auto
如果我评论它,警告就会消失。问题 - 如何自动覆盖此 .gitattibutes
设置?
.gitattributes
覆盖所有配置设置,所以它真的不能被覆盖;可以说是"overrider,"。虽然您可以简单地删除该行,但这将导致其他开发人员的机器出现不一致的行为(如果他们有 core.autocrlf=true
)。所以最好的办法是将以下行添加到 .gitattributes
:* -text
。这将禁用所有文件的 CRLF 处理。
至少在 git 的现代版本中,.git/info/attributes
(或 $GIT_DIR/info/attributes
)会覆盖 .gitattributes
以进行本地配置。
使用* !text
使用core.autocrlf
的值,或* -text
强制不转换。
请参阅 gitattributes
and the text
attribute 的文档。
另请注意: core.eol
, the eol
attribute