core.autocrlf

I just finished tearing apart my git repo and putting it back together. The reason for this undertaking was that a number of lf/crlf EOL errors had crept into my commits somehow. The culprit, as I found out yesterday, was git config’s core.autocrlf configuration option. Initially, it was set to true, meaning that files checked out from a repo are translated from lf to crlf and files committed back in are translated from crlf back to lf. Problem is, I had some files that needed to be checked out as lf in another repository. Foolishly, I set core.autocrlf to false globally. This set in motion a set of events that led to some of my files in the paladin repo being checked in with all the line endings set to crlf. As you may guess, this absolutely destroys any chance of a meaningful review diff being produced. Clearly, this was my fault and I had to own upto it.

This is when I set out to export my commits to patches, clean up the line endings in the patches, remove any nit-picky changes ( ie a change hunk where only trailing whitespace was removed ), shove the changes back into my repo, updated the old branch pointer to look at my shiny new commits, forced github to forget my old history and finally my repo was sanitized.

What I’ve learned from this is to not let anyone or any thing handle things like line endings for me in the future as I may blow it up inadvertently while trying to do something unrelated. core.autocrlf will stay permanently set to false. The solution? My favourite text editor is now set to produce lf line endings by default; let the chips fall as they may.