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

前端 未结 6 1147
旧时难觅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:25

    You can just delete and re-checkout the offending files from the index like this:

    rm 
    git checkout -- 
    

    Or, if they are the only modified files (be careful with this command), you can script it like this:

    git diff --name-only --diff-filter=M | xargs rm --
    git checkout -- .
    

    On a GNU system you can use a slightly safer pipe, but you don't appear to have spaces or other delimiting characters in your filenames in any case.

    git diff -z --name-only --diff-filter=M | xargs -0 rm --
    

提交回复
热议问题