Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EGit and Eclipse modifies .gitignore file but it should not

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?

like image 261
Jeff Avatar asked Jul 19 '13 14:07

Jeff


People also ask

Why is my .gitignore file not working?

Check the file you're ignoring Take a good look at your structure, and make sure you're trying to ignore the file that isn't already committed to your repository. If it is, remove the file from the repository and try again. This should fix the Gitignore not working issue.

What is EGit in Eclipse?

EGit is an Eclipse Team provider for the Git version control system. Git is a distributed SCM, which means every developer has a full copy of all history of every revision of the code, making queries against the history very fast and versatile.

Should .gitignore be ignored?

The . gitignore file's purpose is to prevent everyone who collaborates on a project from accidentally commiting some common files in a project, such as generated cache files. Therefore you should not ignore .

How do I ignore a .gitignore class file?

The easiest and most common way to ignore files is to use a gitignore file. Simply create a file named . gitignore in the repository's root directory. Then, add names and patterns for any files and directories that should not be added to the repository.


1 Answers

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).

like image 145
robinst Avatar answered Oct 22 '22 14:10

robinst