Geekflare is supported by our audience. We may earn affiliate commissions from buying links on this site.
Share on:

2 Easy Ways to Delete GitHub Repository

Easy-Ways-to-Delete-GitHub-Repository
Invicti Web Application Security Scanner – the only solution that delivers automatic verification of vulnerabilities with Proof-Based Scanning™.

GitHub is one of the most popular resources developers use to host and share code and collaborate on different projects. This platform has also become a social networking site where developers collaborate, network, and share ideas. 

If you are looking for ways to delete a GitHub repository, you already know how this platform works. The following are some of the reasons you may consider deleting a GitHub repository;

  • You no longer need the repository: You may have created a one-time project. Or the technologies you used for your source code are obsolete. You can comfortably delete the repository to clean up your GitHub profile. 
  • The repository was created by mistake: You may have been experimenting with GitHub and created your first repository. You can create such a repository and engage in serious development. 
  • You have forked the repository and no longer need the original: GitHub allows users to fork repositories (create a copy of the original). If you decide to focus on developing the fork, you can delete the original as long your repository is public. 
  • The repository contains sensitive information: Mistakes happen. You may find that the repository you published online has some personal or sensitive information or data that should not be in the public domain. You can delete such a repository to protect your privacy. 

Things to know before deleting a GitHub repository

Things-to-know-before-deleting-a-GitHub-repository
  • You can only delete what you own: GitHub allows you to create repositories for free. However, you cannot come across another person’s repository and delete it. However, a contributor within your organization with admin rights can delete a repository. Thus, when adding contributors to your organization, ensure you understand the organizational roles
  • You can restore some deleted repositories within 90 days: GitHub stores deleted repositories for 90 days. You can restore a repository if it is not a fork of a currently empty network. 
  • If you have a public repository and delete the original, all the forks remain: If person B forks a repository from person A, person B gets a copy of the original in their account. However, if person A deletes the original repository, person B’s copy will remain. 
  • If you delete a fork, the original repository remains: If you fork a repository from person A and decide to delete it, the repository on person A’s account will not be affected. 

These are the different approaches for deleting GitHub repositories;

Deleting from the GitHub platform

Step 1: Log in to GitHub

Click on the picture icon on the right side to reveal a drop-down menu

Screenshot-from-2023-04-06-13-33-18

Step 2: Click on “Your repositories”

This tab has all your repositories. 

Screenshot-from-2023-04-06-13-34-47

Step 3: Locate the repository you want to delete

Click on the title of the repository you want to delete. For demonstration purposes, I created a repository named “to-be-deleted.” 

Screenshot-from-2023-04-06-13-39-43

Step 4: Click on the “settings” tab 

While inside the target repository, click on the “settings” icon.

Screenshot-from-2023-04-06-13-41-33

Step 5: Delete the repo

After clicking the “settings,” you will have something similar to this;

Screenshot-from-2023-04-06-13-44-00

Scroll down until you find the last section, “Danger Zone”. 

Screenshot-from-2023-04-06-13-45-31

Click on the last subheading labeled “Delete this repository” in red. 

Screenshot-from-2023-04-06-13-52-48

Step 6: Confirm deletion

A pop-up window will occur for you to confirm your actions.

Screenshot-from-2023-04-06-13-54-11

Click on “ I want to delete this repository” and move to the next step.

Step 7: Read the terms

GitHub shows you what will happen when you delete your repository. 

Click on “I have read and understood these effects” and move to the next step.

Screenshot-from-2023-04-06-13-57-59

Step 8: Type the name of the repository you want to delete

GitHub wants to be sure that you need to do away with the repository for good. Type the repository’s name, and the “Delete this repository” button will be activated.

Screenshot-from-2023-04-06-14-04-17

Click on the button (you may be asked to input your GitHub password). You have successfully deleted your GitHub repository.

Delete using GitHub CLI

You can use the command line interface (CLI) to delete a remote repository hosted on GitHub. To achieve this, you must first install GitHub CLI, authenticate it, and permit it to perform various actions remotely. 

Step 1: Check that you have gh-cli

Run this command; 

gh --version

If the gh-cli is installed, you will have something like this;

image-99

If it is not installed, you can check the installation guidelines here. Follow all the steps and run the gh --version command to confirm everything works as expected.

Step 2: Locate the remote repo

For demonstration purposes, I will use this repository;

image-100

To delete a remote repository using cli, run this command;

gh repo delete [<repository>]

However, replace <repository> with the name of the specific repository you want to delete. (For my case, it is Tkamunya1/bookish-garbanzo

Step 3: Delete the repository

Run this command;

gh repo delete Tkamunya1/bookish-garbanzo

Note: Replace all the contents after the delete word in the above command with your repository name. 

Screenshot-from-2023-04-10-12-38-36

Once you run the command, the command line interface will instruct you to manually type the repository’s name to confirm the deletion. 

Refresh your GitHub page, and you will see something like this;

Screenshot-from-2023-04-10-12-42-40

Other Options

#1. Make your repository private

If you have an awesome product that you don’t want other people to copy its source code, making it private is a good option. A private repository is only accessible to you and the people you give access to. 

Such an approach allows your team to keep collaborating but ensures that your app’s source code is not in the public eye. You can turn your public GitHub repository into a private one using the following steps;

Step 1: Log into your GitHub account

On the right side, click on the picture icon to reveal a drop-down menu

Screenshot-from-2023-04-06-16-29-20

Step 2: Click on “My repositories”

Screenshot-from-2023-04-06-16-29-37

Step 3: Locate the repository you want to make private

Click on its title

Screenshot-from-2023-04-06-16-32-01

Step 4: Click on “Settings”

You will have something like this;

Screenshot-from-2023-04-06-16-32-39

Step 5: Change visibility

Scroll downwards until the last section, named “Danger Zone”. 

If your repository is public, you will see these words;

“Change repository visibility

This repository is currently public.”

Click on “Change Visibility”

Screenshot-from-2023-04-06-16-36-26

Step 6: Accept the changes

There will be a pop-up confirming your actions.

Screenshot-from-2023-04-06-16-38-06

There will be another pop-up to confirm that you understand the effects.

Screenshot-from-2023-04-06-16-39-57

Make the final confirmation.

Screenshot-from-2023-04-06-16-40-54

#2. Delete a specific branch

It is common practice for a GitHub repository to have several branches, especially for a big application. Such an approach ensures that developers can work on various features in isolation, test them and push them to the main branch only when they are sure they work as expected. 

If you have a branch that you may want to delete for one reason or another, these are the steps;

Step 1: Log in to your GitHub account

image-77

Step 2: Locate your profile on the right side and click on “My repositories”. 

image-78

Step 3: Locate the repository hosting the branch you want to delete. 

Screenshot-from-2023-04-06-18-00-02

Step 4: Click on the “branches” icon

The number of branches will depend on your repository. For this case, we have two branches.

Screenshot-from-2023-04-06-18-02-46

Locate the branch you want to delete

For my case, I want to delete the “Titus” branch

Step 5: Delete the branch

On the right-hand side, click the delete icon.

Screenshot-from-2023-04-06-18-03-28

You can see we now have only one branch. 

Screenshot-from-2023-04-06-18-13-11

#3. Delete specific files from the repository

Instead of deleting the entire repository, you can delete a file containing sensitive information. For demonstration purposes, we will delete the README.md file. Follow these steps to delete your selected file;

Step 1: Open your repository

In our case, the repository has 3 files; README.md, index.html, and styles.css files. 

Screenshot-from-2023-04-06-18-13-11-1

Step 2: Open the file you want to delete

In our case, we will delete the README.md file. On the right side, click on the delete icon. 

image-79

Step 3: Commit the changes

Write a commit message to explain why you deleted the file. 

Screenshot-from-2023-04-06-18-19-31

Frequently Asked Questions

Frequently-Asked-Questions
What is the difference between GitHub and Git?

Many people confuse GitHub and Git.
Git is a version control tool that allows developers to track changes in their code.
GitHub is an online platform that allows developers to store, manage code and collaborate. 
To push code from your local machine to GitHub, you need a version control such as Git.

Is GitHub free?

GitHub offers free and paid packages. With a free account, you can create repositories, manage your code and collaborate with others. Paid packages include extra features like GitHub Copilot, an AI assistant that produces code through written prompts.

Are there GitHub alternatives?

Several GitHub alternatives exist, such as GitLab, SourceForge, GitKraken, and Bitbucket. Some of these alternatives are fully paid, while others offer free and paid plans. 

Can you use third-party tools to delete repositories?

Yes. You can use tools like GitKraken, GitHub Desktop, and Bitbucket to manage your remote repositories. However, ensure you only allow third-party tools you can trust to access your GitHub account. 

Conclusion

You can now comfortably delete a GitHub repository, irrespective of your reason. You can also explore other options, such as making your repository private, deleting a specific branch, or deleting files if you still need the source code. 

If unsure which file (s) may contain sensitive information, you can scan the GitHub Repository for credentials. 

Thanks to our Sponsors
More great readings on Development
Power Your Business
Some of the tools and services to help your business grow.
  • Invicti uses the Proof-Based Scanning™ to automatically verify the identified vulnerabilities and generate actionable results within just hours.
    Try Invicti
  • Web scraping, residential proxy, proxy manager, web unlocker, search engine crawler, and all you need to collect web data.
    Try Brightdata
  • Semrush is an all-in-one digital marketing solution with more than 50 tools in SEO, social media, and content marketing.
    Try Semrush
  • Intruder is an online vulnerability scanner that finds cyber security weaknesses in your infrastructure, to avoid costly data breaches.
    Try Intruder