rm
Remove Directories Safely
Remove folder/directory only from index
but not locally.
git rm -r --cached folder_name git commit -m "Removed folder from repository" git push origin master echo "/folder_name" >> .gitignore
- removes the folder from the index
- committing without the folder
- push only the tracked to the remote
- add the folder name to
.gitignore
to prevent further upload/commit
remove folder from
git rm -r --cached --ignore-unmatch
Without --ignore-unmatch
, git will exit with error on the first file not in the index.
Remote has a folder that shouldn't be there
Fixing Hanging Node_module
Uploaded to Remote Repo
Add /node_modules
to the .gitignore
file
- This alone won't remove what is already uploaded to remote
/node_modules
Remove reference with this command (remember to commit everything before doing this)
git rm -rf --cached .
Delete /node_modules
from local project.
Commit this command which will delete the /node_modules
from both remote and local
git add .