Trying to fix line-endings with git filter-branch, but having no luck

后端 未结 8 731
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 09:02

I have been bitten by the Windows/Linux line-ending issue with git. It seems, via GitHub, MSysGit, and other sources, that the best solution is to have your local repos set

相关标签:
8条回答
  • 2020-11-22 09:38

    Follow these steps if none of other answers works for you:

    1. If you are on Windows, do git config --global core.autocrlf true; if you are on Unix, do git config core.autocrlf input
    2. Run git rm --cached -r .
    3. Delete the file .gitattributes
    4. Run git add -A
    5. Run git reset --hard

    Then your local should be clean now.

    0 讨论(0)
  • 2020-11-22 09:40

    Here's how I fixed all line endings in the entire history using git filter-branch. The ^M character needs to be entered using CTRL-V + CTRL-M. I used dos2unix to convert the files since this automatically skips binary files.

    $ git filter-branch --tree-filter 'grep -IUrl "^M" | xargs -I {} dos2unix "{}"'
    
    0 讨论(0)
提交回复
热议问题