How to normalize working tree line endings in Git?

后端 未结 6 1994
甜味超标
甜味超标 2020-11-28 01:17

I have cloned a repository that had inconsistend line endings. I have added a .gitattributes that sets the text attribute for the files I want to normalize. Now

6条回答
  •  鱼传尺愫
    2020-11-28 01:55

    The .gitattributes settings will only affect new commits. If this repository has no history published (no others depending on it), you might want to go through the whole history. In Unix/Linux, you can use dos2unix(1) to fix all files in combination with find(1), and using the history rewriting of filter-branch (see the discussion in the git book) you can even clean up the full history of the project.

    Use with utmost care, on a fresh clone. Get in contact with anybody who might have a clone, and advise them what you want to do.

提交回复
热议问题