How to delete local Git repositories

Greg Foster
Greg Foster
Graphite software engineer

There are times when you may need to delete a local repository—whether to start over, to clean up space, or to remove an obsolete project. This guide will take you through the process of deleting a local repository in Git, explain the difference between local and remote repositories, and provide various methods to accomplish this task.

Before deleting a repository, it's important to understand how Git actually structures its file storage, particularly the difference between local and remote repositories:

A local repository in Git refers to the version of your repository that resides on your local machine. It includes all of your commits and Git history that have been saved locally, allowing you to work on your project, make commits, and use Git's version control capabilities even when offline.

A remote repository is hosted on the internet or on a network server. This can be on platforms like GitHub, GitLab, or Bitbucket. Remote repositories allow multiple developers to collaborate on the same project by pushing to and pulling from the remote repository. The remote repository acts as the central source of truth for all of the other distributed versions of the codebase.

Deleting a local repository involves removing the directory on your computer where the repository is stored. It’s a straightforward process and can be reversed by cloning the remote repository again.

Before deleting anything, make sure that all important changes are either backed up or pushed to a remote repository. Losing data can be quite frustrating and detrimental to your project.

To delete a local repository, you simply remove the repository's directory using your operating system's command line tools:

For Windows:

Terminal
rmdir /s /q "C:\path\to\repository"

This command forcefully removes the directory and all of its contents without asking for confirmation.

For macOS and Linux:

Terminal
rm -rf /path/to/repository

This command recursively deletes the directory and all of its contents.

To remove a repository in GitHub Desktop, follow these steps:

  1. Open GitHub Desktop and select the repository from the repository list.
  2. Click on Repository in the menu bar.
  3. Choose Remove... from the dropdown menu.
  4. You will be given the option to also move the repository to the Recycle Bin. Select as needed and confirm.

If you use Git GUI, the process is similarly straightforward:

  1. Open Git GUI and select the repository.
  2. Go to the Repository menu.
  3. Choose Delete Repository.
  4. Confirm the deletion.

If you need to retrieve the repository again, and it exists on a remote server, you can easily clone it back to your local machine:

Terminal
git clone https://github.com/username/repository.git

Replace the URL with the actual URL of your remote repository.

Note: All of the above methods only remove the repository for you locally. If the remote repository still exists, all of the files previously committed to it will still be intact. In the case you committed sensitive information like an API key or other credentials, deleting your local repository is not enough to mitigate the leak. In the case of such a leak, follow this guide on removing sensitive data from Git.

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2