.gitignore not ignoring .idea path

MrDuk picture MrDuk · Sep 3, 2015 · Viewed 60.3k times · Source

What am I missing that needs to be done in order to get git to ignore my .idea/ path?

ctote@ubuntu:~/dev/1$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   .idea/.name
    modified:   .idea/misc.xml
    modified:   .idea/modules.xml
    modified:   .idea/vcs.xml
    modified:   .idea/workspace.xml
    modified:   src/Receiver.java
    modified:   test/1/agent/WindowsQueryHandlerTest.java

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    lib/
    mp1.iml

no changes added to commit (use "git add" and/or "git commit -a")

ctote@ubuntu:~/dev/1$ cat .gitignore
*.class

# Package Files #
*.war
*.ear

# IDEA config files
.idea/

Answer

Cristian Lupascu picture Cristian Lupascu · Sep 3, 2015

.gitignore only ignores newly added (untracked) files.

If you have files that have already been added to the repository, all their changes will be tracked as usual, even if they are matched by .gitignore rules.

To remove that folder from the repository (without deleting it from disk), do:

git rm --cached -r .idea