65

I'm using eclipse egit with github. I found something strange that I didn't change anything, but egit marked the file as "changed". See the images:

  1. the file "run.bat" is marked as "changed"

    enter image description here

  2. Compare with "file in Git index", you can see nothing is different

    enter image description here

  3. Compare with "file in HEAD", you can see nothing is different neither

    enter image description here

My friend uses mac and I use windows, but we all configured git as "commit unix lineend".. I also checked the lineend of my source and the HEAD, they are the same(I configured git to convert them to "\r\n" when pulling)

Where is wrong? Is it a bug of Egit?

Community
  • 1
  • 1
Freewind
  • 193,756
  • 157
  • 432
  • 708
  • 1
    Check line endings - CR, CR-LF – kan Nov 22 '11 at 13:12
  • "I configured git to convert them to "\r\n" when pulling": that should be the cause right there, no? – VonC Nov 22 '11 at 13:14
  • 1
    Looks like you have mixed line endings in one file. Not sure how it would work then. The automatic conversion is hardly predictable for me, I disable it usually... – kan Nov 22 '11 at 14:03

8 Answers8

62

Eclipse Preferences / Team / Git / Configuration / User Settings

("core" section)

key: autocrlf
value: false

The key should already exist, so just need to edit the value.

If creating a new key then use core.autocrlf.

powtac
  • 40,542
  • 28
  • 115
  • 170
Mark
  • 7,446
  • 5
  • 55
  • 75
  • This doesn't work for me. The *Location* property shown in the User Settings tab is my global gitconfig (`C:\Users\William\.gitconfig`) and has all the correct settings. However, `git commit -m` works fine while Eclipse's *Commit* option nukes my line endings. – wchargin Dec 07 '13 at 17:36
  • 1
    This helped me, but I had to delete the repo and imported it again. – Henrique de Sousa Sep 25 '14 at 09:33
  • Worked once I right-clicked on the project and did `Team->Synchronize Workspace` – Brad Mace Oct 07 '15 at 18:31
  • 3
    In case the key does not exist, use **Add Entry...** with `core.autocrlf` as key and `false` as value, which also triggers the creation of the **core** section. – Jens Piegsa Feb 23 '16 at 22:22
  • This is not a solution: it disables auto-conversion of line endings, which maybe will fix the comparing issue, but will worsen a lot of other things. – zakmck Feb 18 '19 at 10:21
48

One of the first things I've had issues with in Git.

I've said this forever:

git config --system core.autocrlf false

To get rid of CR highlighting in diff and patch views, use:

git config --system core.whitespace cr-at-eol

If you share your computers with others, replace '--system' with '--global'.

user229044
  • 232,980
  • 40
  • 330
  • 338
Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
16

As a follow up, as I just ran into the same issue, another reason for EGit detecting all files as changed is a POSIX file permission problem at least when used together with Cygwin's git.

The following will fix that; however keep in mind that this also means that they are ignored then:

$ git config core.filemode false

Axel Dörfler
  • 379
  • 3
  • 6
9

For eclipse specific issues for linefeed, you can also change the return character in Eclipse Preferences where you can change the New text file line delimiter from Windows syntax to Unix which should help.

Eclipse Next File Line Delimiter settings

Marcus
  • 2,128
  • 20
  • 22
  • 1
    this is the proper answer with autocrlf set to false – Adam Dymitruk Jul 09 '15 at 23:36
  • Changing **just** this preference helped however had to restart my Eclipse after changing that setting. BTW I was facing this problem using Eclipse on Windows 10 and the file being reported as changed on Windows-Eclipse was originally modified on Ubuntu and pushed to remote repo and pulled on Windows machine. Thanks. – Jignesh Gohel Aug 05 '17 at 13:00
8

you can ignore whitespace differences with Eclipse settings under Compare/Patch. Preferences-->General-->Compare/Patch,you can find the "Ignore white space" in the right,and select this option.

lucky8060
  • 81
  • 1
  • 2
  • as well as: Preferences/Team/Git/[box Revionsion Information]"ignore whitespace changes" – Ralph Dec 09 '20 at 14:29
5

I also have the same issue from the Eclipse git commit is showing this issue

once modified file and finally removed the changes from the file even though it showing the file in Un staged changes section.

Solution:
Eclipse -> Window -> Preferences -> Team -> Git -> Configuration -> User Settings (right side tab)

click on Add Entry

Key  : core.autocrlf
Value: true

click on Ok then click on Apply -> Ok Refresh your "Git Staging tab" or check the Team -> commit option. now it will only show the exact changes only.

  • none of this worked for me on Eclipse. I sort of ran some utility which generated few classes but also, changed some alterations in the existing classes. Now, am having a hell of time in filtering the actual changed files with the spaces ones. – winterisComing Oct 24 '19 at 09:30
0

i had the same issue and nothing of the proposed solutions did work. i hat the autocrlf feature turned off, the latest version of egit and git installed. the line endings of the repository and local files were both matching.

the problem was caused by an entry in the .gitattributes:

* text=auto eol=lf

i could therefore:

  • remove the attribute
  • commit the changes

but what also did work was to go to command line and type

git reset --hard

and then refresh in eclipse.

benez
  • 1,856
  • 22
  • 28
-4

In General->Workspace. Select Text encoding UTF-8