Delete a Git Repository
Whether you're tidying up old projects, or need to address a mistake, it's essential to know how to properly delete both local and remote Git repositories repositories.
You probably either want to:
- Delete a local repository on Windows, Linux, OSX, or using VS Code.
- Delete a remote repository on GitHub, GitLab, or Gitea.
Deleting a Local Repository
If you simply wish to delete a Git repository from your local machine, you're essentially looking to delete the
.git folder present in your repository.
Using the Command Prompt or PowerShell:
If you have
.gitmodules files you want to get rid of too:
Of course you can also use Explorer to delete the
To view hidden files and folders in Windows:
- Open File Explorer from the taskbar.
- Select View > Show > Hidden items.
On Linux and Mac OSX:
Using the Terminal:
rm -rf .git
.gitmodules as well:
rm -rf .git*
Mac OS X Hidden Files:
To view hidden folders in Finder (Mac OS X), execute these commands in your terminal window:
defaults write com.apple.finder AppleShowAllFiles TRUE killall Finder
Delete a Git repository using VS Code
If you're using Visual Studio Code, simply navigate to the repository's location and delete the
.git folder to remove the Git repository.
Deleting a Remote Repository
Deleting a GitHub repository:
- Navigate to the main page of the repository on GitHub.
- Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.
- Scroll down to the "Danger Zone" section, and click Delete this repository.
- Read the warnings carefully.
- To verify you're deleting the correct repository, in the text box, type the name of the repository you wish to delete.
- Click I understand the consequences, delete this repository.
Warnings for GitHub:
- Deleting a public repository will not delete any forks of the repository.
- Deleting a private repository will delete all forks of the repository.
- Some deleted repositories can be restored within 90 days of deletion.
Deleting a GitLab repository:
(Note: The exact steps can vary depending on GitLab's version and customizations.)
- Navigate to the main page of the repository on GitLab.com.
- Go to Settings > General.
- Scroll to the "Advanced" section and then choose Remove project.
- Follow the prompts to confirm the deletion.
Deleting a Gitea repository:
- Go to Settings of the repository.
- Navigate to the Dangerous Zone.
- Click Delete this repository.
It's crucial to approach the process of deleting repositories with caution. Always make sure to backup any essential data or code before deletion. Remember, while some platforms offer a grace period for restoring deleted repositories, not all actions are reversible.