Convert all line endings to LF

Why? So that you can check your node_modules folder into git, whether or not there are mixed line endings in files.

Use dos2unix, which you can get using macports:

sudo port install dos2unix

And then use it:

dos2unix filetoconvert.js

To fix all line endings in many files...

find path/to/bad/files/ | xargs dos2unix

And then git add whatever you like and you'll be good to go!


Feb 23 2012, 10:59 PM

Walter Blaurock responded

How about the core.autocrlf setting in git?

Feb 28 2012, 5:53 PM

David Trejo responded:

@walter: Hey, you're totally right.

The main issue is that if you try to git add a bunch of files at the same time, even with that setting set correctly, it will complain about mixed line endings and prevent your from adding those files.

This generally only happens when you try to git add files that are built or auto-generated, or that someone else wrote on a windows computer AND a linux machine, leading to mixing.

David Trejo

Growth Engineer at Credit Karma & consultant. Past clients include Aconex, Triplebyte, Neo, Brown Computer Science Department, Voxer, Cloudera, and the Veteran's Benefits Administration.

Want to be a better Full Stack Growth Engineer?

You'll get articles on everything I learn as a growth engineer at Credit Karma, a profitable private company with >80 million members, >$4 billion valuation, and >900 employees.