"Warning: line endings have changed from 'LF' to 'CRLF'." when files have LF line endings on Windows
See original GitHub issueDescription
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
- Clone https://github.com/testcases/repo-with-lf-endings (can be from within GitHub Desktop or another Git implementation like Git for Windows).
- 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. - 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:
- Created 6 years ago
- Reactions:9
- Comments:14 (3 by maintainers)
Top GitHub Comments
@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:
Execute this commands (In this exact order):
Have you tried a .gitattributes file with:
Or fix by extension file (use only LF):