Bug 300964 - EGit seems to ignore .gitignore's contents
Summary: EGit seems to ignore .gitignore's contents
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement with 1 vote (vote)
Target Milestone: 0.9.0-M2   Edit
Assignee: Stefan Lay CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
: 317772 (view as bug list)
Depends on:
Blocks: 315554
  Show dependency tree
 
Reported: 2010-01-27 05:30 EST by Chandra Sekar S CLA Friend
Modified: 2015-11-04 08:01 EST (History)
23 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chandra Sekar S CLA Friend 2010-01-27 05:30:03 EST
Though I have the following lines in my .gitignore, EGit continues to mark the files/folders with a ? in the Navigator and adds them to Git when I select "Add to Version Control" on the project node.

.classpath
.project
.settings
target
META-INF

This affects when I have created a bunch of new files and would like to add them alone to Git.
Comment 1 jetdog330 CLA Friend 2010-02-02 02:37:41 EST
I'm getting the EXACT same situation right now... and it's being a real drag on my team projects for client-specific configuration!

I used the eclipse way to add things to .gitignore (from team menu), from a Linux client:

In application/logs/.gitignore:
/*.php

In application/config/.gitignore:
/config.php

In system/config/.gitignore:
/database.php

In .gitignore:
/.htaccess

I then went ahead and set the .gitignore on my Linux, committed, pushed, etc.  So the above .gitignore files were added to the tree.  Then I created some of these files locally (i.e. .htaccess from above), then right-clicked the root node->team->"add to version control".  In Linux, the files were properly ignored.

However, on Windows: For all of the above references, having the corresponding files in the project directory causes the referenced files to NOT get ignored, and doing the same "Add to version control" caused all the files that were supposed to get ignored to get added to Git, committed, and pushed upstream :(

Would really appreciate a fast response on this!
Comment 2 jetdog330 CLA Friend 2010-02-02 04:58:24 EST
I just confirmed the above problem in a Windows XP VM.

EGit on Windows does not pay attention to .gitignore files.

Any suggestions on where I can get started on a patch?
(Or workarounds?)

I noticed that the relative path on windows ends in a/b/c/current_repo_folder\FILE ... could the slash orientation have something to do with it?
Comment 3 Doug Schaefer CLA Friend 2010-02-09 11:44:27 EST
See it too. While it continues to mark them with '?', they are ignored at commit time. So this seems to be just a UI issue, but it is really confusing.
Comment 4 Matthias Sohn CLA Friend 2010-03-10 19:30:26 EST
Charley is working on patch http://egit.eclipse.org/r/#change,326 which is related to this issue
Comment 5 Martin Probst CLA Friend 2010-03-26 13:09:18 EDT
I can confirm this issue on a Mac OS X box, so it does not seem to be limited to Windows.
Comment 6 Remy Suen CLA Friend 2010-04-18 07:43:31 EDT
(In reply to comment #3)
> See it too. While it continues to mark them with '?', they are ignored at
> commit time.

I believe this is because the dialog does not pick up on folders that aren't under version control.
Comment 7 Remy Suen CLA Friend 2010-04-18 12:15:21 EDT
(In reply to comment #6)
> (In reply to comment #3)
> > See it too. While it continues to mark them with '?', they are ignored at
> > commit time.
> 
> I believe this is because the dialog does not pick up on folders that aren't
> under version control.

Actually, I take that back. With the changes introduced by bug 303373, even unversioned folders are recursed into now.

However, the code runs a check via Team.isIgnoredHint(IResource) and because the resources in the 'bin/' folder are marked as derived, the contents of the 'bin/' folder do not show up in the commit dialog.
Comment 8 Paulos Siahu CLA Friend 2010-04-23 07:19:20 EDT
I'm using Linux (Ubuntu) and having the same issue as originally reported, i.e. .gitignore seems to be ignored (ironic, but no pun intended). EGit version 0.7.1
Comment 9 Charley Wang CLA Friend 2010-06-09 16:31:26 EDT
Hi Paulos, I'm currently working on a patch to address this issue (http://egit.eclipse.org/r/#change,683). It probably won't make it into the 0.8.1 release, but will hopefully be included in the 0.9 release in September. The feature may be available in nightly builds before the September release, will keep this bug updated accordingly :)
Comment 10 Dobes Vandermeer CLA Friend 2010-06-21 19:18:53 EDT
Not sure how anyone can survive without being able to ignore resources from commit/add :-(.  I guess people are still mostly using the command-line instead of EGit ?
Comment 11 Doug Schaefer CLA Friend 2010-06-21 19:50:30 EDT
(In reply to comment #10)
> Not sure how anyone can survive without being able to ignore resources from
> commit/add :-(.  I guess people are still mostly using the command-line instead
> of EGit ?

Unfortunately, yes. I tried using both since I was doing something a bit complicated (checkout from hg, gitignore .hg, check into git). The difference you then get between the command line and egit is unsettling.

That and I'm not sure the Ignore menu item from egit was working or maybe I had messed things up by that point. My guess is that Ignore would add the resource to a gitignore file.
Comment 12 Chris Aniszczyk CLA Friend 2010-06-21 20:31:12 EDT
We are working on the functionality for the 0.9 timeframe...

http://egit.eclipse.org/r/#change,683

Give us a few weeks :)
Comment 13 Matthias Sohn CLA Friend 2010-06-24 09:27:21 EDT
*** Bug 317772 has been marked as a duplicate of this bug. ***
Comment 14 Matthias Sohn CLA Friend 2010-06-28 18:33:12 EDT
this is caused by missing functionality
Comment 15 Marius Kotsbak CLA Friend 2010-07-08 15:34:49 EDT
This is really a blocker for us to move from svn to git on more projects, as many prefer to use eclipse to commit to svn and need to be able to continue doing that after gitification.
Comment 16 Stefan Lay CLA Friend 2010-07-22 10:39:56 EDT
Patch for review: http://egit.eclipse.org/r/#change,1167

With this patch the add command can be used to add files to the repository and it will comply with the .gitignore rules.

The Track command will be removed in a subsequent commit.

Further things needed to do:
- Do not show label decorator (question mark) for ignored files
- Do not show ignored files in commit dialog (as untracked files)
- Any further idea?
Comment 17 Stefan Lay CLA Friend 2010-07-29 10:26:51 EDT
.gitignore handling in add action was submitted as df27ebc65d7eb50b3c8eae96155e58c865241b7e
Comment 18 Stefan Lay CLA Friend 2010-07-29 10:27:52 EDT
The Track menu entry was removed with f1a567951bf1c9a0aca47afafffde930b9740cf3
Comment 19 Chris Aniszczyk CLA Friend 2010-08-04 11:10:00 EDT
We should be covered with .gitignore support in EGit by 

d418845e423fe8a39242bad850429ad84b814404
fa7caf467ea4d031e0b996ba65218e8724a1d630

Please open any issues as you come across them.
Comment 20 Justin Buser CLA Friend 2012-06-20 19:53:58 EDT
This bug seems to be related to an issue Eclipse has with hidden files, I've found that .gitignore files that are hidden aren't parsed by Egit.
Comment 21 Christian Jean CLA Friend 2014-11-02 21:51:36 EST
Is there a regression on this?

I'm using Version: Luna Service Release 1 (4.4.1), Build id: 20140925-1800

In my build scripts, I generate various info files.  I do not want to add those to my SCM (git) so they are in my .gitignore file (one folder up, not the root one).  

I realized that after I build, Eclipse keeps adding these files to my "Unstaged Changes".

So I spawned a linux VM, cloned my project and built it.  I make sure that these info files have been created.  Then execute a 'git status' to determine that git is not attempting to stage anything, so it is working in Linux.

Why is Eclipse not working as expected or like the Linux version does?
Comment 22 Francois Guillot CLA Friend 2014-12-08 17:51:25 EST
(In reply to Christian Jean from comment #21)
> Is there a regression on this?
> 
> I'm using Version: Luna Service Release 1 (4.4.1), Build id: 20140925-1800
> 
Does the bug Bug 453852  happen to you as well ?
Comment 23 Lina Kemmel CLA Friend 2015-11-04 08:01:34 EST
(In reply to Christian Jean from comment #21)
> Is there a regression on this?
> 
> I'm using Version: Luna Service Release 1 (4.4.1), Build id: 20140925-1800
> 

I see this also on java-neon-M2-win32-x86_64, Windows 7.