How to delete a deleted Github repository?

Asked

Viewed 691 times

-2

I recently deleted a repository with the name JS and the Github has the option to restore repositories (Settings/Repositories/Deleted repositories) deleted which does not actually delete the repository, just creates a Backup from the repository, what I want is to create a repository again named JS only that the system does not leave returning a message saying that the repository is already existing and that I can not create a repository with the same name, so as I do to get around this problem do not want to restore the repository JS and having to erase file by file to have a new empty repository would take more work.

  • This answers your question? Delete a particular repository from github

  • Not to delete an existing repository but to delete a repository that has already been deleted.

  • I don’t know how you deleted it, since Github permanently deletes it. You have tried to restore and delete it as mentioned link?

  • 1

    No mate! Github does not permanently delete the repository, there is the option to restore the deleted repository https://help.github.com/en/github/administering-a-repository/restoring-a-deleted-repository.

  • If you restore the repository, and clone on your machine you can delete all the files at once, then just commit and sync, so the repository is empty again. @felipecardozo

  • When you say that the "system" is not leaving it is Github itself that is giving this message or is using some tool to create the repository on Github?

  • Yes! Github himself.

  • 1

    Samuel Renan Gonçalves Vaz, yes! only that as mentioned in the question would be more work since I look for a more agile solution to do, this because in the future it may occur again and I will have to repeat the same steps and can also have other people with the same problem.

Show 3 more comments

5 answers

5


There is no way to delete the repository before 90 days of backup, but I advise starting the project from scratch so you don’t have to wait as long.

Just start a new local project:

git init

Configure the origin of your repository:

git remote add origin https://github.com/user/repo.git

Add a readme or . gitignore and commit first

git add .
git commit -m "Primeiro commit"

Remove the protected’s master branch, which is taught here! Last force sending (Lost all master history):

git push origin -f

If you have other branches remove them from the remote with:

git push origin :nome-da-branch

or

git push origin --delete nome-da-branch

1

Not much to do if you want to reuse the name of Repo, will give a job.

First you’ll have to restore the Reset on Github and then clone it to your machine. Then you will have to delete the master branch on your machine as follows:

git clone https://github.com/user/repo.git # seu repo

git branch nova-branch # cria a nova-branch
git checkout nova-branch # troca para a nova-branch
git branch -D master # deleta localmente a branch master

Then push the new-branch to Github:

git push origin nova-branch # faz o push para o Github

Then go to Github and access the repository settings in: Settings -> Branches, and switch Default Branch to a new branch.

After that, you’ll be able to push the removal of the master branch:

git push origin :master # faz o push da remoção da branch master

If you want, you can now generate a new master branch and change the default on Github.

  • 1

    Do you really need all this dancing? I would just start a new local project, add the remote, and use a git push -f origin master - and then, it excludes the other branches of the old project.

0

Respositories are available for 90 days. After this period, they will be permanently removed.

More details here. Below the extracted stretch.

Please also keep in mind that:

Deleting a private repository will delete all of its forks.
Deleting a public repository will not delete its forks.
You can restore some deleted repositories within 90 days. For more information, see "Restoring a deleted repository."

So those are the options:

  • wait for 90 days
  • or rename the project and then delete
  • 1

    That’s right @Petersmith, the only way is to delete and wait 90 days. Safety issue. Avoid accidental deletion. Either change your name or wait 90 days.

0

You can start a new Github repository from scratch under another name. After past the days when the deleted repository gets "backed up" you rename Github repository.

Remote Urls do not necessarily need to be updated as Github redirects the URL to the new repository name, but it is advisable to update for good practice.

To update the remote URL just run:

git remote origin set-url <nova-url>

-1

Friend, as seen Github has this security policy of keeping a history of your repository for 90 days before actually deleting.
An idea to get around this would be, before deleting, change the name of the repository and then delete it, so the name you want would be available to use.
In your case, as you have already deleted the repository, you could simply restore it, rename it, delete it again.
I believe it is the best option since you don’t want to have to delete all the files to continue using the same.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.