git prune

Administration

Delete unreachable objects


The 'git prune' command deletes loose objects that no branch, tag, index or reflog entry can reach — for example commits left behind long ago. It is part of git gc, which you should normally use instead. Pruned objects cannot be recovered.

Synopsis

git prune [-n] [-v] [--expire <time>]
[ ] optional| or<arg> placeholder... repeatable--flag option

Examples

Preview

git prune -n -v

What would be deleted.


Through gc

git gc --prune=now

The usual way.

Workflow Examples

1
git reflog expire --expire=now --all

Forget the reflog

2
git prune

Delete the now-unreachable objects

Troubleshooting

Nothing is pruned

Cause: The reflog still references the objects

Expire the reflog first (or wait 90/30 days)

Tips & Pitfalls

Best Practices

  • ✓Use git gc instead of calling prune directly.

Common Mistakes

  • ✗Confusing git prune with git remote prune (which removes stale remote branches).

FAQ

A:

No. Run git fsck --lost-found first if in doubt.