Read Anthropic’s case study about Graphite Reviewer

How to delete local Git repositories

Greg Foster
Greg Foster
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


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:

Join 20,000+ developers at top companies
Stop wrestling with Git commands
The Graphite CLI takes all the pain out of Git, allowing you to ship faster and stop googling Git commands.
main
diff1
diff2

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.

Join 20,000+ developers at top companies
The best engineers use Graphite to simplify Git
Engineers at Vercel, Snowflake & The Browser Company are shipping faster and staying unblocked with Graphite.
main
diff1
diff2

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.

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2