If you need to remove a file that has already been committed to the Git tree, you can use the git rm command. It will remove the specified file from the index AND from the disk.
git rm FILE_PATH
But what if you still want to keep the file locally? For example, it might be a file that was accidentally committed and that you still need. 🤔
Fortunately, Git provides an argument you can add to remove the file from the index only:
git rm FILE_PATH --cached
With this simple argument, you'll be able to keep the file in your project while deleting it from Git! 😉