I had to delete a the last 5 commits from a local git repo, I did so by reset --hard
to the new HEAD commit:
git reset --hard abcde1
Now I need to remove those unreferenced commits from the history, after reading many answers here I tried running the following.
git gc --prune=now
and
git prune --expire=now --agressive
None of the answers I found seem to work for me, for example I can still see a those commits with git show <sha>
, what am I missing here? Is possible to remove a commit from history completely?
And finally, if I push to a new origin (let's say it's a completely new repo) are those unreferenced commits also pushed?