Try again, this time using newren/git-filter-repo
, which will replace BFG and git filter-branch
As mentioned in its documentation:
[there is] an extra steps to delete the other tags and do another gc are still required to clean out the old objects and avoid mixing new and old history before pushing somewhere
git filter-repo
does avoid confusing users (and prevent accidental re-pushing of old stuff) due to mixing old repo and rewritten repo together.
Note: on the server side (ie, where you are pushing to), a git gc needs to be run, which is done regularly but not immediately.
That is the case for GitHub, as well as BitBucket.
See Atlassian documentation "How to perform a manual garbage collection on a repository"
Bitbucket implements its own garbage collection logic without relying on git gc
anymore (this is achieved by setting the [gc] auto = 0 on all repositories).
When a fork is created, the pruneexpire=never is added to the git configuration and this is removed when the last fork is deleted.
As mentioned here:
BitBucket will run git gc
themselves in response to doing git reset --hard HEAD~1
(which discards last commit) followed by git push -f
.
So in your case:
git commit --allow-empty -m "empty commit"
git push
git reflog expire --expire-unreachable="30m" --all
git prune --expire="30m" -v
git gc --prune="30m"
git reset --hard HEAD~1
git push -f
And a git gc
should be done on BitBucket side!