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.