49

I'm using Eclipse and EGit, but Eclipse modifies my .gitignore file without me asking to do so. As soon as I open Eclipse the .gitignore file is modified.

I've added some folders to .gitignore (through EGit) but removed them after, but Eclipse keeps adding removed lines to .gitignore.

  1. git checkout .gitignore, I get the good version of the file
  2. Then I go to Eclipse window
  3. Then I go back to terminal and issue: git status,
  4. I can see that .gitignore is now modified.

How can it be?

robinst
  • 30,027
  • 10
  • 102
  • 108
Jeff
  • 979
  • 3
  • 10
  • 18

1 Answers1

109

By default, EGit automatically adds resources marked as "Derived" to .gitignore. A typical example is the bin folder in a Java project containing the compiled classes.

You can disable this by going to Window > Preferences > Team > Git > Projects and deselect "Automatically ignore derived resources by adding them to .gitignore".

There was also a bug in EGit where it added entries when the Eclipse model and the filesystem were out-of-sync, see bug 421610 (fixed for EGit 3.5).

Steve Chambers
  • 37,270
  • 24
  • 156
  • 208
robinst
  • 30,027
  • 10
  • 102
  • 108
  • I think you're right, by removing my project from eclipse it removed the configuration (derived files selection included) – Jeff Jul 23 '13 at 08:33
  • I'm seeing this exact symptom with Eclipse Kepler Service Release 2, but I don't find the checkbox you refer to, so I can't disable it. Is there a property I can edit, or some other way around this? BTW, thanks for explaining why this is happening. – philwalk Jul 17 '14 at 23:09
  • @philwalk: It's still at the same location in the Eclipse preferences (just checked). – robinst Jul 19 '14 at 03:44
  • 1
    For Eclipse 4.4 (Luna), the full path is Window -> Preferences -> Team -> Git -> Projects -> "Automatically ignore derived resources by adding them to .gitignore" – proski Jul 16 '15 at 20:31
  • thank you, I was using autoderiv and that meant that "stuff" ended in my .gitignore without reason – Vito De Tullio May 11 '22 at 07:23