How to remove unused git commits remote?

0

Issue

recently I cleaned up my git repo by using git rebase -i --root master. I squashed a few commits together, edited some, set the time accordingly and at the end I used git push --force-with-lease origin master to push my local state to remote.

This worked just fine and my repo is now cleaned up as seen here, but somehow I was able to find an old commit hash and when searching for it explicitly via the url, I am still able to view the old tree that is not used anymore as seen here.

So my question is if and how it is possible to delete these old commits/trees from my remote repository?

Any ideas?

Solution

“Removing” a commit does not actually remove it: it sticks around for a while. You just can’t find it any more unless you have saved the hash ID somewhere.

You saved the hash ID, 3597386eaa550367e5531e4ec019f04e1d7e40df. More precisely, the GitHub URL you saved includes the hash ID, which you then present to GitHub, so that they can use the hash ID on their side—and that still locates the commit, which is still there.

It will continue to be there until it isn’t. Exactly when that will be is hard to say: Git has a maintenance command that cleans up unused commits. In your own copy of the repository, you can run this maintenance command on your own schedule. In the copy over on GitHub, you’re at the mercy of their maintenance schedule.

(If it’s really important, you can ask the GitHub folks to do an early cleaning. However, most things that you could handle this way—such as getting rid of a commit that exposed a password—are well into the “too late” period by the time you can actually get it done, so there’s rarely any reason to bother with this.)

Answered By – torek

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More