Is it possible to delete a repository on Github using Git codes?

Asked

Viewed 330 times

3

I have a repository on Github that’s public and it has 33 commits, but I no longer have access to Github’s email and password (so I can’t delete the repository from Github), but I still have access to the repository saved on my computer, I can commit, push and pull on the remote repository. My problem is that this public repository has codes that shouldn’t be public, so I need to erase it.

Knowing this is possible, is it possible to delete the repository only using Git codes? I don’t think so, but I don’t have the knowledge to say...

  • Git is not possible, but you can use something like the Github CLI for this: https://hub.github.com/hub.1.html

1 answer

2


Yes, it is possible.

First you have to delete your commits locally:

This command deletes the last commit

git reset --hard HEAD~1

Then run this command to apply the changes to the remote repository:

the + sign before the branch name we’re pushing tells git to push

git push origin +master

If you want to delete files containing code, or sensitive data you can see here how to do.

  • Hello @Mauroalmeida, in case I would just delete the commits and not the repository itself, correct?

  • Hello @D.Watson, yes, exlcui the commits and not the repository, I couldn’t find a way to delete the repository using commands.

Browser other questions tagged

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