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


I have a repository on Github that is 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 through Github), but I still have access to the repository saved in mine computer, I can perform commits, push and pull to the remote repository. My problem is that this public repository has codes that shouldn't be public, so I need to delete it.

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


Yes, it is possible.

First you have to drop 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 name of the branch we are pushing tells git to force the push

git push origin +master

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

Scroll to Top