mlevytskiy
mlevytskiy

Reputation: 1665

Trouble with command `git rm -r --cached /.idea`

In my case I have new project. Developer before me commit all files in git (with build folder, .idea folder etc). I create .gitignore and now I want delete autogeneric and system files. Earlier I do same in 3 step: 1) remove all autogeneric and system files in repository; commit and push on git. 2) create and fill .gitignore; commit and push 3) restore removed file (ussually via IDEA recreate project from gradle.build)

Now I try new way without deleting files from repository: 1) create .gitignore 2) use commands: git rm -r --cached .gitignore, git rm -r --cached /.idea; etc 3) after that I going to commit and push. 4) use command: git add . and commit and push again

But I have trouble with command git rm -r --cached /.idea

fatal: /.idea: '/.idea' is outside repository

Help me fix this problem=)

Upvotes: 1

Views: 910

Answers (2)

mlevytskiy
mlevytskiy

Reputation: 1665

I find easier way=)

git rm -r --cached . 
 git add .
 git commit -m 'Removed all files that are in the .gitignore' 
 git push origin master

Upvotes: 0

uwolfer
uwolfer

Reputation: 4516

You want to use git rm -r --cached ./.idea.

Note the / in /.idea: this will look up in the root filesystem.

Upvotes: 2

Related Questions