Delete a folder in github, but not in local

In order for you to remove the folder or file from Github but no from you computer use this command in the following order

  1. git rm -r --cached name-of-the-folder
  2. git commit -m "insert your comment inside this quotation marks"
  3. git push origin

in case you have several branches you can do

  • git push origin master
  • git push origin branchName

EXAMPLE

  1. git rm -r --cached .vscode
  2. git commit -m "removed the .vscode folder"
  3. git push origin

It seems like the --cached option of git rm is what you want.

git rm --cached fileToDelete
git commit master
git push origin master
Now add the file to .gitignore

Not tested though.

Tags:

Git

Github