Jaroslav Klimčík
Jaroslav Klimčík

Reputation: 4838

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?

Upvotes: 0

Views: 7401

Answers (3)

DotSam
DotSam

Reputation: 1

The problem could be because you are not in the directory of the file you want to remove.

Move to the directory and run

git rm -rf --cached .idea

And also don't forget to add it to your .gitignore file!

Upvotes: 0

iltempo
iltempo

Reputation: 16012

.idea is not tracked yet by git. You cannot remove it from the repository. What you probably want to do is excluding it from git by adding the directory to the .gitignore file.

Upvotes: 0

torek
torek

Reputation: 489718

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.

Upvotes: 7

Related Questions