Skip to content

How to Remove a directory from Git Repository

Covers
Git
Versions & support
About Git →

Use rm -r switch with the git command to remove directory recursively. After removing the directory you need to commit changes to the local git repository. Then push the changes to remove the directory from the remote git repository.

Use the command line below to remove the directory named test_dir from the current directory.

git rm -r test_dir

Then commit and push to apply changes in the local and remote repository.

git commit -m "Removed test directory"
git push origin master   # Change 'master' with your branch name

All done, The test_dir has been removed from the local as well as the remote git repository.

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top