Home Software Engineering How To Delete a GitHub Repository

How To Delete a GitHub Repository

by schkn

As a web developer or a software engineer, you are probably using GitHub repositories on a day to day basis.

As time passes, you may want to get rid of some of your GitHub repositories, often to focus on other projects you are more interested in.

In this tutorial, we are going to see how you can easily delete GitHub repositories.

Delete GitHub repository

Deleting GitHub repositories is pretty straightforward.

The process is the same whether you are dealing with public or private repositories.

In order to delete a GitHub repository, you have to follow the steps described below :

  1. Click on your profile picture at the top right corner of the GitHub interface and click on “Your repositories“.
  2. On your repository list, select the GitHub repository that you want to delete.
  3. On the repository page, click on “Settings” in the menu.
  4. In the repository settings, scroll down until you see the “Danger zone“.
  5. In the “danger zone”, click on “Delete this repository
  6. To confirm the GitHub repository deletion, you have to type the repository name. When you are done, simply click on “I understand the consequences, delete this repository“.
  7. Congratulations, you have successfully deleted your GitHub repository!

Delete GitHub repository with screenshots

In case you had trouble following the steps described above, here are all the screenshots that will guide you in deleting your GitHub repository.

1 – Click on your profile picture and select the “Your repositories” option.

repository menu on Github

2 – Given the list of repository that you own, select the one that you want to delete.

repository list on github

3 – When you have navigated to the repository main page, click on “Settings” in the repository menu.

github repository settings

4 – Now that you clicked on “Settings”, scroll down until you reach the “Danger zone” of your repository.

In this zone, you have the option to delete your GitHub repository, click on it to proceed.

delete this repository option on Github

5 – When clicking on “Delete this repository“, you will be asked to provide the repository name in a field in order to confirm that you want to delete this repository.

Type the repository name and click on “I understand the consequences, delete this repository“.

delete github repository confirmation

6 – In some cases, you are asked to provide your user password in order to confirm the deletion.

Type your user password and click on “Continue”

confirm github password

7 – Back to the home page, an information message will appear to notify you that you have successfully deleted the Github repository.

repository successfully deleted

Delete Local GitHub Repository

In some cases, you don’t want to delete a remote GitHub repository but you only want to delete the copy you got by cloning the remote repository.

In order to delete a local GitHub repository, use the “rm -rf” on the “.git” file located at the root of your Git repository.

$ rm -rf <repo_folder>/.git

By deleting the “.git” file, you will delete the Github repository but you won’t delete the files that are located in your project folder.

As a consequence, you will be able to initialize a new Git (or Github) repository using “git init”, add a remote using “git remote add” and start committing new files!

$ git init

$ git remote add origin [email protected]:<user>/<repository>.git

$ git push -u origin master

Careful, if you use the “git push” command without the “-u” option (for upstream branch), you will be asked to provide the upstream branch.

Make sure to read our dedicated tutorial if you want to find more information about upstream branches.

Conclusion

In this tutorial, you learnt how you can easily delete Github repositories.

You have seen the detailed steps to get rid of your Github repository remotely, but also locally by using the “rm” command.

If you are interested in Git, GitHub and software engineering, we have a complete section dedicated to it on the website, so make sure to check it out!

delete github repository

You may also like

2 comments

Dawal February 27, 2022 - 10:07 am

I found it very helpful. keep on the good work

Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.