Make Git “LF will be replaced by CRLF” warnings go away

前端 未结 6 1148
旧时难觅i
旧时难觅i 2020-12-07 14:06

I have setup Git so it doesn\'t commit inconsistent line endings. The problem with that is a whole pile of files appear modified even though they are not. What do I type to

6条回答
  •  执笔经年
    2020-12-07 14:34

    This might happen if you change core.autocrlf config variable (if I understand your problem correctly).

    If you are at clean state, i.e. just after commit, and you don't have uncomitted changes, forced re-checkout and removing index should do the trick:

    The below command git reset --hard HEAD will make your current branch to point to the latest commit and all uncommitted code will be lost. Make sure to commit the code or take the backup

    $ rm .git/index
    $ git reset --hard HEAD
    

    That, I think, would sync both working area files, and the index (staging area) to follow crlf settings.

提交回复
热议问题