How to Delete a GitHub Repository
Learn all the important things about deleting GitHub repositories.
It is easy to create new repositories in GitHub.
And that becomes a problem when you have created way too many of them. Specially when you don't need them anymore.
In this tutorial, I'll show you how to delete a GitHub repository. I'll also answer some common questions around deleting GitHub repositories.
Deleting a GitHub repository
Deleting a GitHub Repository is simple, just follow the steps below ->
Log in to your GitHub Account and Go to Your Repositories, then Open the GitHub Repository you want to delete.
After that, you need to go to the Settings tab, which you will find at the top of the front page of the repository.
After that, scroll down to the bottom of the General Settings, until you reach the Danger Zone (sounds dangerous, because it can be)
So you ready? Click on that "Delete this repository" button at the last, in 3, 2, 1, Go!
Oh, you got a pop-up!
Okay, you may proceed by clicking on "I want to delete this repository", and...
A New Warning!
Huh, seems like a lot of warnings as if we were destroying the whole world, isn't it?
You may proceed and click on that button to tell GitHub you understand what you are doing... (You do understand, right? Well continue reading as we will cover what are the consequences of deleting a repo)
And yeah, you need to type what they are asking you to type, that is basically
your_Username/the_Repo_Name. Nope, you can't copy-paste! You need to type it.
Why so much trouble just for deleting a repo? Well, this typing confirmation is basically to give you some time to think if you actually want to do it, as you need to be mindful while typing.
After typing, just click on the "Delete this repository" button. After that, you may be asked for either your GitHub Password or a 2FA code if you have set up that.
And then, you are Done!
Things to remember about deleting a GitHub repository
These are the warnings mentioned in the Official GitHub Docs & a few more from our side:-
- Deleting a repository will permanently delete release attachments and team permissions. This action cannot be undone.
- Deleting a private repository will delete all forks of the repository.
- Deleting a public repository will not delete any forks of the repository.
- Deleting a fork, will (obviously) not have any effect on the upstream (the repository it is forked from) repository.
And if forgot that warning text you got while deleting the repo, it said,
"This will permanently delete the username/repo repository, wiki, issues, comments, packages, secrets, workflow runs, and remove all collaborator associations."
So keep those things in mind.
Can you really not restore a deleted repo? (Yes & No)
The answer is yes if your repository was not a fork. If it was a fork, you can still do it, but not by yourself, you need to contact GitHub Support for that.
To restore a deleted Repository, follow the steps below -
Go to GitHub and click on your profile icon at the top right in the navbar
Then scroll down and find Settings
Then you may need to scroll down the sidebar and Find the
Repositories button under the Code, planning, and automation section
Then click on the Deleted Repositories button under the Repositories heading
And inside that, you will find that all the Repositories you deleted not more than 90 days ago. Do keep in mind there will be some side-effects of that, for example, the issues won't have the labels on them, etc.
But things get tricky if your Repository is a part of a Fork Network. As the GitHub Docs says,
"A fork network consists of a parent repository, the repository's forks, and forks of the repository's forks. If your repository was part of a fork network, it cannot be restored unless every other repository in the network is deleted or has been detached from the network"
So, I hope you have a pretty good idea of what all goes while deleting a GitHub repository. Thanks for reading, keep GitHubing! & take care 😄