7

I have 2 files that won't go away in the Changes view. If I look at the diff, it just tells me the committed version has LF line endings and the local version has CRLF line endings. I'm working on a Mac and I understand linux based systems use LF line endings and Windows use CRLF. Is there someway I can just convert these 2 files so all the line endings are LF?

Thanks.

Patrick Grimard
  • 6,599
  • 6
  • 43
  • 63

7 Answers7

8

I had the issue on Windows because I checked out the project using a Cygwin git.exe and IntelliJ used a git.exe from msysGit. Changing the git.exe under Settings -> Version Control -> Git -> Path to Git executable fixed the problem.

Sonata
  • 1,880
  • 23
  • 31
  • 1
    I also had this issue and this helped but I did have to revert all improper line endings so that the diff showed no more differences. – Scott Mar 23 '17 at 18:04
6

In your case, you could:

  • convert those files

  • set core.autocrlf to input:

    git config core.autocrlf input
    
  • reset it (make sure you don't have any work in progress)

    git rm --cached -r .
    git reset --hard
    

See more at "git replacing LF with CRLF".

mehmet
  • 6,023
  • 3
  • 31
  • 42
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
3

Simple and quick solution to is - Shelve & Unshelve the changes. Works for me every time.

Shelving:

enter image description here

Unshelve:

enter image description here

Johnny
  • 10,849
  • 11
  • 61
  • 105
1

I had this issue on windows when repository was cloned using Cygwin (even with git config core.autocrlf true).

After re-cloning the repository with GitBash (configured as git config core.autocrlf true), the problem went away.

coldserenity
  • 5
  • 1
  • 1
1

After a lot of trial and error, this following list finally works on windows:

  • IntelliJ settings->version control->git path to git executable should use the git.exe in c:\cygwin\bin
  • IntelliJ settings->version control->git ssh executable 'native'.
  • edit environment variables to your account on windows add to path: c:\cygwin\bin and c:\cygwin
  • get rid of the .idea in the project directory if it's already there. (very important !)
  • restart intellij, open the project directory again.

So now the local changes won't show the 'identical content' files, and the 'pull' and 'push' are all working from IntelliJ. And I don't have to go to cygwin to do the chore anymore.

If the project is being worked on both Linux and Windows, make sure the following setting is followed: Make sure you have this setting (git config -l) in the cygwin window: core.autocrlf=input

on linux in order for things to work properly you also have to have this setting as well: core.autocrlf=input

this is how to set it: git config --global core.autocrlf input

cheers!

truthseeker
  • 369
  • 1
  • 4
  • 7
0
git config core.autocrlf true

did the trick in my case, see https://www.jetbrains.com/idea/help/handling-lf-and-crlf-line-endings.html

Tim Büthe
  • 58,799
  • 16
  • 82
  • 126
0

There seems to be an issue when you git clone the repository via Cygwin git executable and IntelliJ uses the git exectuable at C:\Program Files\Git\bin\git.exe.

I solved this by cloning the project again via intellij (ctrl-shift-a : "check out from version control" -> Git).

Now everything seems to be in order and I can't see any changes until Version Control.

vikingsteve
  • 34,284
  • 19
  • 101
  • 142