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=)
You want to use git rm -r --cached ./.idea
.
Note the /
in /.idea
: this will look up in the root filesystem.