Git and IntelliJ line separator issue

I work in IntelliJ 15.0.3 and using Git via Git Bash (to commit and push changes). When I fetch file from a remote Git repository, it contains different line separators (mixed mode or whatever it's called). I mean, some lines end in CRLF , and some lines end in LF (same file).

When I make changes to IDEA, the file is automatically saved, and all line separators are reduced (changed) to the default line separator IDEA ( LF for me).

And Git treats these changes as changes to the file, as a result, I commit the file with changes such as these:

 - some line + some line 

Because some line [CRLF] been changed to some line [LF] .

How do I configure Git ignore this or how do I configure IntelliJ IDEA to leave the file in this mixing mode? I do not want to commit changes when there are no changes.

+3
git intellij-idea
source share
3 answers

When installing git, we will have the opportunity to install checkout as-is commit as-is .

If this is not set, we can do with git config .

This command helps you with this.

  git config --global core.autocrlf true > 

According to the documentation:

  git          CRLF  LF,      ,  ,        .        core.autocrlf.  youre   Windows,    true -   LF-  > 
+5
source share

IDEA delegates change permission on git.

Thus, you will need to either force the use of line breaks in IDEA , or to force the desired line breaks in git .

In my case, autocrlf true already present on my PC, but the working copy was originally copied from the collegue share, where it was checked with a different parameter.

A clean check will solve the problem, but I had some files that were already modified, and they wanted to save them. This can be circumvented by resetting the git index for the entire project or just the desired subdirectory .

0
source share

In my case, the problem was that some files were push ed with different line separators - one file could contain CRLF as well as LF , and for these files there was no way to change anything, the problem described above.

IntelliJ has a preconfigured line separator, and every time I made any minor changes to the file, all line separators were replaced with IntelliJ configs, which means that git treated some lines as changed, even though actually there were no changes.

My solution was to switch to Eclipse (I just didn’t want to deal with it), and Eclipse doesn’t change it, so after editing in Eclipse git only the changes that I make are displayed.

-one
source share

All Articles