I have a GitHub repo that had two branches - master & release.
The release branch contained binary distribution files that were contributing to a very large repo
You can (as detailed in this answer) permanently remove everything that is referenced only in the reflog.
NOTE: This will remove many objects you might want to keep: Stashes; Old history not in any current branches; etc. Read the documentation to be sure this is what you want.
To expire the reflog, and then prune all objects not in branches:
git reflog expire --expire-unreachable=now --all
git gc --prune=now
git reflog expire --expire-unreachable=now --all
removes all references of unreachable commits in reflog
.
git gc --prune=now
removes the commits themselves.
Attention: Only using git gc --prune=now
will not work since those commits are still referenced in the reflog. Therefore, clearing the reflog is mandatory. Also note that if you use rerere
it has additional references not cleared by these commands. See git help rerere
for more details. In addition, any commits referenced by local or remote branches or tags will not be removed because those are considered as valuable data by git.