2

My git history looks like this:

          | -> X
          |
| -> X    | -> X
|         |
| -> X    | -> X         | -> X
|         |              |
C -> C -> C -> C -> C -> C -> C -> HEAD
|         |
| -> X    | -> X
          |
          | -> X
          |
          | -> X

This happens when force pushed to previous commits, which I think ruins the purpose of force pushing to get rid of accidentally committed sensitive information, as anyone with the hash can still see all the changes.

How can I permanently delete the old X commits, both locally and on remote upstream (github)?

I have managed to clear the ones displayed in git fsck --unreachable --no-reflog using git reflog expire --expire=now --expire-unreachable=now --all and git gc --prune=now --aggressive, but I know there are more commits not displayed there that I can access in github, I had it bookmarked to test this (this might actually be on a non-existant branch that I deleted long ago, but even in that case my question stands).

And also the just expired/removed commits still exist on github, I cant force push. So how do I force delete the remote files that I can access using the hashes that I pruned?

I know there are many similiar questions but I can't seem to find one asks the exact same thing, or close enough to figure out for myself.

John Smith
  • 33
  • 4
  • I don't believe you can delete objects, specifically, on a remote. It is up to the configuration of the server to remove "dangling" objects (garbage collection) that were caused by e.g. a rewrite of some objects (because of a rebase, for instance). – zrrbite Sep 26 '20 at 21:47
  • I've closed this as a duplicate, but if it's not specific to GitHub, let me know and I can re-open. – torek Sep 26 '20 at 22:40

0 Answers0