How to Delete a Repository in GitHub

How to Delete a Repository in GitHub

ยท

6 min read

GitHub is a popular web-based platform used by developers and programmers to store, manage, and track changes to their code projects. Known as "repositories" in GitHub, these project folders contain all files and historical changes for the code.

There may come a time when you need to completely remove a repository from your GitHub account. Perhaps the project is no longer active, or the repository contains sensitive information that should be deleted. Fortunately, GitHub allows you to fully delete repositories through some simple steps.

When Can Repositories Be Deleted

Before deleting a GitHub repository, it's important to understand the circumstances when this action can be performed:

  • Personal repositories - Any repositories owned by your personal account can be deleted at any time. This does not impact any forks or local clones made by other users.

  • Organization repositories - If you have admin permissions for an organization, you can delete any of its repositories. Regular organization members cannot delete repos.

  • Public forks - Public forks created from other repositories can also be deleted by the fork owner (your account).

So essentially, your own personal and organization repositories, plus public forks created by you specifically, can be removed from GitHub through deletion.

Steps to Delete a GitHub Repository

Deleting a repository in GitHub only requires a few steps:

1. Navigate to the Repository Settings

  • Go to GitHub.com and log into your account if necessary.

  • Find the repository you want to delete and click on it.

  • Click on the Settings tab in the top middle of the page. This opens the settings page.

2. Scroll to Delete Repository

  • In the left sidebar menu, scroll down and click Delete This Repository. This brings up the deletion confirmation box.

3. Read Warnings and Type Name

The confirmation box will provide warnings about permanently deleting the repository. Read through these carefully!

You must then type the full name of the repository in the field to confirm.

For example, if deleting "MyProjectRepo", type "MyProjectRepo"

4. Click Delete Repository Button

After reading all warnings, understanding the implications, and typing the repository name - click the red Delete This Repository button on the bottom.

5. Check the Deleted Repository Page

You will be taken to a new page showing the repository as deleted with a helpful recovery section in case deletion was an accident.

And that covers the full process! By following these simple steps you can completely remove repositories from your GitHub account or organizations. Just make sure you have proper authorization and double-check names before committing to the permanent deletion.

Why Delete a GitHub Repository?

There's usually a good reason when fully deleting a repository rather than just archiving it. Here are the most common scenarios that motivate users to remove repositories:

  • The project is cancelled or retired and you don't want stale repositories littering your profile. Keep it clean by deleting it.

  • Open source project has pivoted or been rebuilt in a new repo. Delete the old one to reduce confusion.

  • The repository contains API keys, passwords or other sensitive credentials or data. Safest completely remove it.

  • Organization is changing structure or focus and the content no longer fits. Delete rather than a permanent inactive presence.

  • Forked repository originated from an inappropriate source or has issues. Delete your fork entirely.

  • Realize you should not make the code or content publicly available after creating it. Need to fully remove traces from GitHub through deletion.

Essentially, deleting repositories allows you to fully remove stale, problematic, unnecessary or inappropriate repos from the social platform rather than having them persist. This keeps your profile, organizations and activity more accurate and secure.

What Happens When a Repository is Deleted?

When a repository is deleted either by yourself or a GitHub admin, here is what happens to it:

  • The repository immediately disappears from view on GitHub for all users.

  • Any forks of the repository will remain intact for fork owners.

  • All issues, stars, followers, etc associated with the repo will be removed.

  • Pages sites hosted for the repo through GitHub will be deactivated.

  • GitHub wiki data will be deleted.

  • Statistics graphs and contributor information will disappear.

  • Any local clones on personal machines will still contain all files and git history.

  • Backups taken of the repository should still be intact through those archives.

  • Recovering a deleted repo is extremely difficult and rare. Assume permanent removal.

So in summary, traces of the repository disappear from the social GitHub platform - but local user copies and forks will continue living on. Issues that depended on the project will no longer have reference.

Is There Any Chance of Recovering a Deleted GitHub Repository?

Yes, there is a small chance of recovering a deleted GitHub repository in some cases:

Within 90 Days of Deletion -

For the first 90 days after a repo is deleted, GitHub retains the repository content in its system before permanent disposal. If the deletion was accidental, you can contact GitHub support within this window and request recovery. They may be able to fully restore it.

Backups and Archives -

If any users made backups or archives of the GitHub repository before it was deleted, those copies of the files can serve as a way to "recover" it. You won't be able to restore the live GitHub integration, but can regain all the code and git history information from backups.

Local Clones -

Anyone who created a local clone of your repository through git clone before deletion still retains the full copy on their local machine. You can request them to re-upload the code to GitHub to get it back.

Forked Repositories -

If other GitHub users have forked your repository before deletion, then that fork essentially acts as another complete copy of the project. You could request the fork owner re-establish the original from their forked version.

GitHub Data Recovery -

In the very worst case where re-uploading from clones/forks is impossible, GitHub does provide extremely limited data recovery services. However, it starts at $9,000 USD (tentative) for basic repos and has no reputation for successfully restoring entire lost repositories.

The only thing you need to keep in mind is to act quickly if possible within 90 days and rely on backups from users who interacted with the repository prior to its deletion. Preventing accidental deletion is always the most surefire way to avoid losing data.

Concluding Thoughts

While deleting repositories is permanent and significant, it is a useful GitHub feature for removing stale or unnecessary projects. Just be 100% certain before moving ahead with removal.

When needed, follow the settings deletion steps outlined here while logged into an account with proper permissions. If you have further questions about safely deleting GitHub repositories without impacting important user data, contact the official GitHub support channels for guidance.

ย