Search code examples
gitintellij-ideaphpstormgit-rm

Git - rm --cached .idea and fatal pathspec


I'm using PHPstorm and I want to remove hidden folder .idea from git index. When I used $git status I got

C:\Program Files (x86)\Ampps\www\1stenglish IS [master +1 ~0 -0 !]> git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       .idea/
nothing added to commit but untracked files present (use "git add" to track)

But when I want to remove it from git index with command git rm --cached .idea/ I got error

fatal: pathspec '.idea' did not match any files

I tried different options of path but without result:

git rm --cached .idea
git rm --cached .idea/*
git rm --cached 'C:\Program Files (x86)\Ampps\www\1stenglish IS\.idea'
git rm --cached 'C:\Program Files (x86)\Ampps\www\1stenglish IS\.idea\'

What I'm doing wrong?


Solution

  • An "untracked" file is one that is neither in the current ("HEAD") commit, nor in the current index (AKA staging area).

    git rm --cached tells git to remove something from the current index.

    If the path is not in the index—and "untracked" means this must be the case—and you then ask git to remove it from the index, what error would you like? :-)

    If you want git to (1) continue to leave the path untracked, and (2) just shut up about it, see gitignore.