The task – to remove file from the Git (and leave it in the filesystem).
The problem occurs when you commit some file into the Git accidentally. This file will be under version control even if you put into .gitignore file. For me it’s often happens with *.iml files.
To solve this problem you need to:
- Add file to .gitignore;
- run command git rm --cached _filename_ to remove files from Git control;
- run git add -u – this tells git to automatically stage tracked files — including deleting the previously tracked files.
- and finally git commit -m "file deletion"
That’s all! Files are removed from Git and still available locally.