Remove Directory from Git in 3 steps Quickly

Remove Directory from Git

Git is a version control distributed system, we use git for managing our code in the simplest way. In this article, I have explained how to remove directory from Git using some commands.

How to Remove Directory From Git

Step 1: Navigate to Local Directory

In the command line navigate to local directory where Git already initialised.

$ cd git_directory //Navigate to the directory

Step 2: Select the Directory to Remove from Git

Now, select the sub directory from the directory to remove from Git. To do that run following command.

$ git rm -r sub_directory_1

This will delete the directory from the current directory.

Step 3: Git Commit and Push the Changes

Commit the changes with nice git commit message and finally push the code to the Git remote repository.

$ git commit . -m "Remove duplicated directory"
$ git push origin <your-git-branch> (typically 'master', but not always)

Important Git Commands

  • git init
  • git clone
  • git branch
  • git checkout
  • git add
  • git commit
  • git pull
  • git push
  • git diff
  • git status
  • git merge


In this short tutorial, you have learned to remove directory from Git. Follow the steps to delete the directory. If you have any doubt, please comment below. I will definitely reply to all your queries.


Please enter your comment!
Please enter your name here