Sometimes you want to remove a directory but keep it locally on your box. So you want to exclude it from the repository, but keep it locally.
Need
We wanted to remove compiled VuePress Doc files from our Github repository. That can be done with a few easy steps. Steps I decided to write down so I can use them again in the future.
Gitignore
Exclude the directory in your .gitignore
resources/docs
That will exclude it if it is in Laravel resources. This you do so they do not get added again after you removed them from the repository.
Git Cache Directory Removal
Then you can remove the folder form the git cache so it will be removed from the repository, but keep your local copy. This can be done using:
git rm -r --cached myFolder