I have a git commit history like this:
U
/
A---B---C---D---E master
Nothing points to the commit U
, but I
Eventually it will be cleaned up by git, but you can look into git gc to actually force a garbage collect.
The clean
command is different and won't take care of this for you.
As described here, simply use
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.