How do I completely remove a commit from GitHub?

On GitHub, I forked the repository and cloned it on my PC. Then, for testing purposes, I edited the file, made a commit, and pushed it to GitHub. But now I would like to completely remove this commit.

I did the following:

git reset --hard <sha1_of_previous_commit>
git push --force

      

It looked fine, but my commit was still available on GitHub at the URL with the SHA1 of my commit. So I deleted the repository on GitHub, then the url said "Not Found".

But if I create the same repository again, my commit is available again at that url. Please help me how the hell can I get rid of this commit?

+3


source to share


3 answers


It is possible that the commit will always be available via the URL. But it is not featured on Github, so I can't see how it is a problem if there is no sensitive information in it.



Subsequent commits will have unique hashes.

+1


source


" Removing sensitive data from the repository " is quite clear:

It's important to note that these commits can be accessed from any clones or forks of your repository, directly through their SHA-1 hashes in cached views on GitHub, and through any pull requests that reference them.
You can't do anything with existing clones or forks of your repository, but you can permanently delete all cached views of your repository and pull requests to GitHub by contacting GitHub support.



In your case, there was (hopefully) no fork / clone, but you need to contact GitHub support to request gc on their version of the repo so that the commit is no longer available via its SHA1 URL.

+1


source


This worked for me:

I have reset the head to 2 seconds ago

git reset --hard HEAD~2

      

and the force pushed my branch to remote

git push -f origin my_branch_name

      

I didn't see any trace of commits when the repo was remote.

0


source







All Articles