我已经在Windows上配置了git,使用命令 git config --global core.autocrlf false
,这样git在检出文件时不会自动将LF行尾转换为CRLF。
当我在Windows上创建新文件并添加时,会得到以下输出。
git add windows-file.txt
warning: CRLF will be replaced by LF in windows-file.txt.
The file will have its original line endings in your working directory.
当将windows-file.txt添加到git索引中时,git会将我的行尾从Windows更改为Unix,这正是我想要的。
但是,我的问题是工作目录版本没有更改。我该如何配置git,以便同时更改工作目录和git索引的行尾?
更新:
在添加和提交后,即使本地工作目录版本具有Windows行尾,并且存储库版本具有Unix行尾,git状态也不显示任何差异。
更新: 在存储库根目录的.gitattributes文件中的内容。
# Set default behaviour, in case users don't have core.autocrlf set.
text eol=lf
# These files are text and should be normalized (convert crlf => lf)
*.java text
*.xml text
*.cmd text
*.sh text
*.txt text
*.md text
*.js text
*.jsp text
*.html text
*.htm text
*.vm text
.project text
.classpath text
*.properties text
*.txt text
*.bat text
*.launch text
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.jar binary
*.class binary
*.gz binary
*.tar binary
*.dll binary
*.exe binary
*.zip binary
git status
显示文件是否不同(即脏文件)? - asmgit config --global
更改全局设置。可能仍然存在本地的每个存储库设置。git config core.autocrlf
显示什么? - mvp.gitattributes
文件吗? - mvp