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

后端 未结 8 900
被撕碎了的回忆
被撕碎了的回忆 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:19

    git status --short|grep "^ *M"|awk '{print $2}'|xargs fromdos
    

    Explanation:

    • git status --short

      This displays each line that git is and is not aware of. Files that are not under git control are marked at the beginning of the line with a '?'. Files that are modified are marked with an M.

    • grep "^ *M"

      This filters out only those files that have been modified.

    • awk '{print $2}'

      This shows only the filename without any markers.

    • xargs fromdos

      This takes the filenames from the previous command and runs them through the utility 'fromdos' to convert the line-endings.

提交回复
热议问题