Line Endings Are Dumb

I have happily acquired a new Mac Book (yay!) and a new work computer (Windows). So, I've been making One Drive exceedingly unhappy moving GBs of file from one to another.

As I was working on reconnecting my GitHub repositories to the files, I was trying to understand why several of my repos were saying I had a bunch of file changes but nothing in the files themselves had changed. I noticed they were mostly .csv files and a few other odds and ends (.R, .Rmd)…

I am well aware that Mac and Windows don't always use the same line endings - this was something that I thought was mostly fixed in OSX but alas, every time I would go to use perl (I love perl, don't @ me), I would remember that Mac text files != to Windows text files. Helpfully, GH desktop does warn you of this, but I was totally ignoring the little triangle icon that said “hey line endings are doing a thing here”.

However! I am flabbergasted we've never had this issue before. My direct research group is 80% Mac people, but we have more than a handful of Windows folks. How have I literally never had this problem until now? We've dealt with .gitignore Windows and Mac helper files, but not line endings? I live and breathe csv files!

First, make sure you have Git installed, so you can work on the command/terminal to update the required settings. You can install Git from here. I generally try to avoid the command line, as I can easily screw something up, but I have learned how to fix things this way when the desktop app just will not do.

Then I worked on following the directions provided by the GitHub folks here: https://help.github.com/articles/dealing-with-line-endings/. I updated the global settings on each computer and restarted for good measure to see what might happen next.

The Windows machine wanted to sync and change the line endings from LF to CRLF. Since CRLF is the global configuration it wants, I pushed those changes and waited to see what my Mac might do. Thankfully, the answer was nothing! Woo! I didn't do the .gitattributes steps just yet - I will wait and see if any of my collaborators have these issues, and then figure out from there what we need to do to fix everyone's machines. I'm also not ready to do that set of attributes for all my repos.

Hopefully this post helps someone else looking for the answer on why their repositories are syncing strangely.

comments powered by Disqus