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?
The reason Git doesn't see any changes is because it applies the autocrlf transforms before comparing the file to the previous revision.
The best policy for line ending management is to disable autocrlf and friends and manage your files manually, unless you have very specific requirements, especially if you have files that need to be in CRLF, since Git doesn't have an option for 'commit files as CRLF', only 'check out files in CRLF'. There are several scenarios in which Git can get confused or cause unexpected results (e.g. downloading the file directly from GitHub etc will download it as LF, changing settings after a file was committed can lead to uncommittable changes, etc).
autocrlf input
means Git will convert CRLF to LF on committing, which is rather misleading (calling it autolf
would be more appropriate in this case).