Deleting a Git repository means removing the entire project folder and its version history from your computer or server

The actual deletion is straightforward — you simply delete the folder containing the .git directory. But before you do, you need to decide whether you want to keep a backup, whether the repository exists in other places (like GitHub or GitLab), and whether anyone else is still using it. A repository stored only on your machine is safe to delete once you confirm you do not need the history. A repository that is also hosted online or shared with teammates requires more care.

The steps differ slightly depending on whether you are working on Windows, Mac, or Linux, and whether the repository is local-only or connected to a remote service like GitHub. This guide covers the most common scenarios and what to check before you delete.

Key Takeaways

  • Deleting a repository means deleting the folder that contains the .git directory — the folder that holds all version history and configuration.
  • Before you delete, check whether the repository exists on GitHub, GitLab, or another remote service, because deleting your local copy does not remove it there.
  • If the repository is shared with others, tell them before you delete it so they do not lose work or push changes to a repository you have removed.
  • On Windows, use File Explorer or the command line to delete the folder; on Mac and Linux, use the terminal with the rm -rf command.
  • If you think you might need the repository again later, create a backup or export the history before deleting.

Check whether the repository exists on a remote service

Before you delete anything, open the repository folder on your computer and run git remote -v in the terminal or command prompt. This command shows you whether the repository is connected to a remote location like GitHub, GitLab, Bitbucket, or your company's own server.

If the output shows a URL (usually starting with https:// or git@), the repository is connected to a remote. Deleting your local folder will not delete the remote copy — it will still exist on GitHub or wherever it is hosted. If you want to remove the remote repository as well, you need to delete it separately through that service's website or command line.

If the output is empty or shows nothing, the repository exists only on your computer. You can delete it safely without affecting anyone else, as long as no one else has a copy they are actively working on.

Confirm no one else is using the repository

If this is a shared repository — one that teammates clone and work on — tell them before you delete it. Deleting a repository that others are actively using can cause confusion and lost work if they try to push changes to a repository that no longer exists.

If the repository is on GitHub or GitLab and other people have cloned it, they will still have their local copies. But if they try to push changes or pull updates, they will get errors because the remote no longer exists. The safest approach is to archive the repository on the remote service instead of deleting it, so others can still see the history and clone it if needed, but no one can push new changes.

Delete the repository on Windows

Open File Explorer and navigate to the folder containing the repository. Right-click the repository folder and select Delete. Windows will move it to the Recycle Bin, where you can recover it if you change your mind within a few days.

If you want to delete it permanently without using the Recycle Bin, hold Shift while right-clicking and select Delete. This bypasses the Recycle Bin, but the folder is harder to recover afterward.

Alternatively, open Command Prompt or PowerShell, navigate to the parent directory of the repository folder, and run rmdir /s /q repository_name (replace repository_name with the actual folder name). The /s flag removes the folder and everything inside it, and /q skips the confirmation prompt.

Delete the repository on Mac and Linux

Open the terminal and navigate to the parent directory of the repository folder using cd. For example, if the repository is in your home directory, run cd ~. Then run rm -rf repository_name (replace repository_name with the actual folder name).

The rm command removes files and folders, -r tells it to remove recursively (including everything inside), and -f forces removal without asking for confirmation. This command is permanent — the folder does not go to Trash and cannot be recovered easily. If you are unsure, run ls first to confirm you are deleting the correct folder.

If you want the folder to go to Trash instead of being permanently deleted, use rm -r repository_name without the -f flag, or use the Finder to drag the folder to Trash.

Delete the remote repository on GitHub or GitLab

Deleting your local folder does not remove the repository from GitHub, GitLab, or other remote services. To delete the remote, you need to access the repository's settings on that service.

On GitHub, go to the repository page, click Settings (near the top right), scroll to the bottom, and click Delete this repository. GitHub will ask you to type the repository name to confirm. On GitLab, go to Settings > General, scroll down, and click Delete project. Other services have similar options in their settings pages.

Deleting a remote repository is permanent and affects everyone who has cloned it. If you are not sure whether you need it, consider archiving it instead — most services offer an archive option that hides the repository from view but keeps the history intact.

Back up the repository before deleting if you might need it later

If you think you might want the repository again in the future, create a backup before you delete it. The simplest way is to copy the entire folder to an external drive or cloud storage. This preserves the .git directory and all history.

Alternatively, run git bundle create repository_name.bundle --all in the repository folder. This creates a single file that contains the entire repository history. You can store this file anywhere and restore the repository later by running git clone repository_name.bundle. This method takes up less space than copying the entire folder.

Frequently Asked Questions

Will deleting the local repository folder affect my remote repository on GitHub?

No. Deleting the folder on your computer removes only your local copy. The remote repository on GitHub, GitLab, or another service remains unchanged. Other people can still clone it and see the history. If you want to remove the remote as well, you must delete it separately through that service's website.

Can I recover a deleted repository?

If you deleted the folder to the Recycle Bin or Trash, you can restore it by opening Recycle Bin or Trash and dragging the folder back. If you used a permanent delete command (like rm -rf on Mac or Linux, or rmdir /s /q on Windows with Shift), recovery is difficult. If you created a backup or bundle file before deleting, you can restore from that instead.

What happens if I delete a repository that other people are working on?

If the repository is local-only and shared through a network drive, deleting it removes everyone's access. If it is on GitHub or GitLab, others still have their local copies, but they cannot push changes or pull updates from the remote. Tell teammates before you delete a shared repository so they can save their work and understand why the remote is gone.

Should I delete the repository or archive it?

Archive the repository if you might need to reference the history later or if others might want to view it. Delete it if you are certain you will never need it and want to free up space. Archiving on GitHub or GitLab hides the repository from your profile but keeps it readable; deleting removes it entirely.

How do I delete a repository without using the command line?

On Windows, use File Explorer to navigate to the folder, right-click it, and select Delete. On Mac, use Finder to drag the folder to Trash. Both methods move the folder to Recycle Bin or Trash, where you can recover it if needed. If you want to delete it permanently without recovery, use the command line instead.