question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Warning: line endings have changed from 'LF' to 'CRLF'." when files have LF line endings on Windows

See original GitHub issue

Description

As initially noticed in https://github.com/desktop/desktop/pull/1906#issuecomment-359083709 and observed further in #3828, GitHub Desktop presents an erroneous warning about line endings for text files with LF line endings in the working directory.

This bug is not affected by the setting of core.autocrlf. I haven’t tried changing the value of core.eol: it might impact this, but the behavior with its default value of native is a bug, so whether changing core.eol changes the behavior or not isn’t really relevant.

Version

GitHub Desktop version: 1.0.12

OS version: Microsoft Windows [Version 10.0.15063]

Steps to reproduce

  1. Clone https://github.com/testcases/repo-with-lf-endings (can be from within GitHub Desktop or another Git implementation like Git for Windows).
  2. Edit README.md to make a content change to the file in an editor that allows you to switch between CRLF and LF line endings (such as Atom, via the line-ending tile on the footer status bar). Save the file with LF line endings.
  3. Open the repository in GitHub Desktop.

Expected behavior:

GitHub Desktop should present the changes as normal, with no remarks about the line endings (as the LF line endings in the working copy of the file match the LF line endings of the file as recorded within the repository data).

Observed behavior:

An svg.octicon.line-endings warning-triangle element containing a title with the content Warning: line endings have changed from 'LF' to 'CRLF'. appears next to the svg.octicon.status-modified status icon in the div.changed-file div.header when reviewing the changed file. (The use of CSS selectors in this description is to communicate the precise location of the erroneous element.)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

69reactions
brcontainercommented, Jan 30, 2018

@stuartpb Isn’t configuration from Github Desktop, you using Windows, Git assumes CRLF, but your “text editor” uses LF only.

Or you change your text editor to CRLF or in your “local repository” change to use only LF using Git commands, example:

In Github Desktop select your repository and in menu go to Repository > Open in Command Prompt:

Repository > Open in Command Prompt

Execute this commands (In this exact order):

git config core.eol lf
git config core.autocrlf input
26reactions
brcontainercommented, Jan 22, 2018

Have you tried a .gitattributes file with:

* text=auto

Or fix by extension file (use only LF):

*.svg text eol=lf

Note: for disable autocrlf run this command:

$ git config --global core.autocrlf false
Read more comments on GitHub >

github_iconTop Results From Across the Web

Git replacing LF with CRLF - windows - Stack Overflow
Whenever you git checkout something, all text files automatically will have their LF line endings converted to CRLF endings.
Read more >
CRLF vs. LF: Normalizing Line Endings in Git
When normalization is enabled, line endings in your local and remote repository will always be set to LF and never CRLF . However,...
Read more >
Windows git warning LF will be replaced by CRLF is ... - Edureka
The file will have its original line endings in your working directory.", path); else /* i.e. SAFE_CRLF_FAIL */ die("LF would be replaced by ......
Read more >
Resolved: Git warning LF will be replaced by CRLF in file
warning : LF will be replaced by CRLF in ansible.cfg. The file will have its original line endings in your working directory.
Read more >
Warning: LF will be replaced by CRLF : r/git - Reddit
Unix represents the end of a line as a line feed (LF) while windows uses carriage return and line feed (CRLF). So the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found