git orphans

Find all objects that aren’t referenced by any other object

Git alias:

orphans = fsck --full

Example:

git orphans

To help an orphan, we can create a new branch with the orphan’s commit hash, then merge it into our current branch:

git branch foo <commit>
git merge foo