2

I mistakenly committed some files with the CRLF line endings.

Now I set core.autocrlf = false and fixed the files locally (in the editor).

Is there a way to fix this (e.g., using some combination of rebase -i &c) so that CRLF completely disappear from history permanently?

sds
  • 58,617
  • 29
  • 161
  • 278
  • 2
    this seem to contain useful hints, hope it helps (see also the contained "renormalize" info): https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/#normalizing-line-endings-in-git-with-gitattributes – Gunnar Aug 23 '23 at 15:56
  • If you use `rebase -i`, you can always squash the commit that introduced the CRLFs with the one the removed them and there won't be a trace in history after that. – DecimalTurn Aug 25 '23 at 04:19
  • @DecimalTurn: how do I know which commit introduced CRLF? What if a commit that killed CRLFs was also doing something else? – sds Aug 25 '23 at 17:08
  • Hopefully the list of possible commits isn't too long and you can check them individually with one of the commands [here](https://stackoverflow.com/q/3920650/5958842). Some Git UI tools also offer the possibility to see line endings in the diff. – DecimalTurn Aug 25 '23 at 17:37
  • Regarding the case where the commit "that killed CRLFs" is also doing something else, it depends. If it's important for you to keep each commit doing only one thing, then squashing won't work. You could instead use the "edit" option for the commit that introduced CRLFs and replace the CRLFs with LFs in an editor (or the command `dos2unix ` is also an option). Note however that you might have some merge conflicts to resolve afterwards if you've edited the same lines in future commits. – DecimalTurn Aug 25 '23 at 17:48

0 Answers0