How can I delete a folder from a git branch?


the folder to be deleted

I have already written git rm --cached -r 'hw 1, try 1', nevertheless the folder stayed in the master branch.


Try this steps:

1) git rm -r 'hw 1, try 1'
2) git commit -m "your-comment-for-deletion"
3) git push origin <your-branch-name>

Note that if you just want to remove it from your git repository but not delete it from your local filesystem you should replace step number 1 with:

git rm -r --cached 'hw 1, try 1'      

** If the above steps doesn’t work, try to force the deletion of the directory:

git rm -rf 'hw 1, try 1'

Answered By – Ran Turner

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published