Git files modified after checkout, reset --hard, etc. even though autocrlf is set to false

柔情痞子 提交于 2019-11-30 06:46:30
Cris Favero

This problem can be caused by gitattributes' text option https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

This problem can be fixed by temporarily editing your .gitattributes file within your project folder.

change * text=auto to #* text=auto make the necessary changes to files line endings and push your commit. You can then enable it again after the change has been made, or alternatively select one of the other options that may better suit your project.

Samuel

I didn't have a gitattributes file as is mentioned in the accepted answer, it was a file permissions problem in my case. To see if this is your problem check the changed files' differences with git diff, e.g.:

git diff path/to/file.html

If the only change you see is old mode/new mode, it's likely a permissions problem. You can tell git to ignore file permission changes using:

git config core.filemode false

or

git config --global core.filemode false

(depending on how you use git).

I recently switched from using Cygwin git to git for Windows for performance reasons, plus so that TortoiseGit works properly, this may be the reason permissions were thrown off in my case.

References:

  1. How do I remove files saying "old mode 100755 new mode 100644" from unstaged changes in Git?
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!