0

I'm dealing with two Git branches, one of which has to be merged into the other periodically.

A long CSS file that is nearly identical on both branches has LF line endings on one branch and CR+LF on the other.

So, any changes to the file on one branch cause a merge conflict spanning the whole file, and I've essentially had to make the same changes manually on the other branch.

Of course, I could just convert the line endings on one of the branches and commit. But is there a better way to do it (e.g using a .gitattributes file) to make git ignore the line endings and avoid any illegible (full-content-replaced) diffs?

laurt
  • 1,811
  • 3
  • 15
  • 18
  • The question is whether the CSS file has been committed with CR+LF line endings to the repository in that other branch, or whether different `.gitattributes` settings make the file appear different in the working trees when checking out the branches. In the first case (CR+LF in the repository), the proper fix *is* to convert the line endings to LF and commit the file. – sschuberth Nov 09 '16 at 15:19
  • If you are stuck dealing with CR-LF, use the `merge.renormalize` setting as in the second-most-voted-up answer in the duplicate. If not, I prefer @sschuberth's solution myself (make one commit that does nothing *but* remove the carriage-returns), but your tastes may differ. – torek Nov 09 '16 at 17:09

0 Answers0