Sunday, August 23, 2020

How to Delete a Repository in GitHub

A few weeks ago, after spending several days learning about Git and GitHub, I was ready to clean up my lab environment. Unfortunately, one of the things I didn't learn, was how to delete a repository on GitHub. It took a bit of digging, but I was able to find out how to delete a repository. So, in the interest of saving others some time, here's how to delete a repository on GitHub.

If you'd rather watch me demo this, there's a short video on the TechSnips YouTube channel.



The Current Situation

We'll start out by taking a look at our local repo. A quick ls shows us that we have two files, Awesome-Script-2.ps1 and our README.md file.
Running git status shows us that we are on the master branch, with nothing to commit, and we are up to date with our repo on GitHub.
Over on GitHub, we can see that the Awesome-Script-2 repository contains the same two files.

Disconnect the Local Repository from GitHub

As we're looking to keep our local repository intact on our local computer, we simply need to run git remote remove origin to disconnect the GitHub repository from our local one. We can confirm this worked by running git status, which shows us that we are no longer connected to GitHub, as the message about being up to date is now gone.


Delete the GitHub Repository

Back over to GitHub! To delete the Awesome-Script-2 repository, we need to click on 'Settings'.
Then we need to scroll all the way to the 'Danger Zone' at the bottom of the page. (Does anyone else feel a song coming on?) Here is where we'll find the option we're looking for. Click on 'Delete this repository', then enter the repository name to confirm.
Finally we can click on 'I understand the consequences, delete this repository'.
Back on the home screen we can see the confirmation that the repository was successfully deleted.
That's all there is to it!