How can I disable diff in line separators in IntelliJ IDEA?

37,122

Solution 1

In the bottom right of your window, change [CRLF] to [LF]

Solution 2

I'm also developing on windows and Because our servers are powered by Linux and all the code has to base on Linux I have preferred to change all my files to LF instead of CRLF.

from git command line:

git config --global core.autocrlf false

i'm working with intellij idea so it's quite easy:

1) File --> settings --> editor --> code style: (for any new file will be created)

a. Scheme : default

b. Line separator: unix and os x (\n)

2) mark the root of the project --> file --> line separator --> LF unix and os x (\n) (for exist files)

Remark: you can also use apps like dos2unix.exe or some other scripts.

than I did using my command line: (you can do this also from the idea)

git commit -m "bla bla"
git add .
git push origin master

since then, I didn't got those warnings

Solution 3

If you came to this thread like me seeking an answer as to why your unit test (JUnit) fails on comparing generated JSON (or any other structure that contains line separators) with one written by hand, you should replace \n by \r\n (for Windows) in your string. The instructions given above don't work for this case.

UPD.

Share:
37,122
avfrolov
Author by

avfrolov

Java developer

Updated on April 23, 2020

Comments

  • avfrolov
    avfrolov about 4 years

    I'm using Intellij IDEA 14 on Windows and Git as VCS on Unix server. The line separator in Windows is CLRF (\r\n) and LF (\n) in Unix. In Git, I'm using config --global core.autocrlf input. This will translate all CRLF's to LF's upon commit.

    When I'm using "Reformat code" option on well-formatted file, IDEA marks files as changed and shows diff in line separators only.

    Right mouse button on changed file -> Git -> Compare with Latest Repository Version

    How can I disable that in IDEA?

  • avfrolov
    avfrolov over 9 years
    but it shows diff in external tool (ex, Git Extensions) as empty changed file and I can't commit this file.
  • Vishy
    Vishy over 9 years
    Hmm I use git inside intellij. It's much simpler to use imho.
  • Vadzim
    Vadzim almost 7 years
  • chorn
    chorn almost 5 years
    just setting the config didn't change the working tree, pulling didn't either, so i had to clone the repository, and then the line separators were fixed.
  • Zopy
    Zopy about 4 years
    Thanks dude, that's exactly why I came for :D
  • Peter
    Peter over 2 years
    Which compare window do you mean?