For files: git rm --cached file-to-remove.md
For directories:
git rm --cached -r dir-to-remove
Sometimes I decide to stop tracking code in git but do not want to delete said code from my local machine. While using git rm or git rm -r would remove code from both git and my local machine, the --cached flag specifies that code should only be removed from the git repository.
Reference: