Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

accidentally changed line ending in git, now can't change back because it says nothing changed

A few days ago, I accidentally changed the line endings of some file, and committed the change. (Was CRLF, is now LF by mistake.) I still don't know if this was my editor being too clever, or perhaps git being too clever. (Actually I suspect it's git, based on my experiences trying to undo this.) Either way, it's done and I'd like to fix it. I thought I could just change the line endings in my editor, then do a commit with just the line ending change. Git refused, claiming I didn't change anything. So I added a dummy change as well, but it then committed the dummy change but also transformed the line endings, so they are still LF. Possibly relevant git settings:

C:\Users\ZKZ4PL2\eqs\hot-connect>git config core.eol

C:\Users\ZKZ4PL2\eqs\hot-connect>git config core.autocrlf
input

Any ideas?

like image 695
Mark VY Avatar asked Jan 26 '26 22:01

Mark VY


1 Answers

First, set core.atocrlf to false, in order to avoid any automagic eol transformation by Git.

 git config --global core.autocrlf false

Second, check any .gitattributes files, for core.eol directives in it.

If you have none, then changing EOL in your editor should be picked up on git add.

like image 184
VonC Avatar answered Jan 29 '26 13:01

VonC