如何让git更改工作目录中的行?

ams*_*ams 9 git

我在配置的窗口上有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.
Run Code Online (Sandbox Code Playgroud)

因此当将windows-file.txt添加到我想要的git索引时,git正在将我的行结束从windows更改为unix.

我遇到的问题是工作目录版本没有改变,如何配置git以便它改变工作目录和git索引的行结尾?

UPDATE

在add和commit git status之后没有显示任何差异,即使本地工作目录版本具有Windows行结尾并且repo版本具有unix行结尾.

更新 repo根目录下的.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
Run Code Online (Sandbox Code Playgroud)

lak*_*tak 5

如果您没有未提交的更改,请尝试:

git rm --cached -r . 
git reset --hard
Run Code Online (Sandbox Code Playgroud)

删除本地文件并从索引中获取它们。