git-prune
Prune unreachable objects from the object database
TLDR
SYNOPSIS
git prune [-n] [-v] [--progress] [--expire time] [--] [heads...]
DESCRIPTION
git prune removes loose objects from `.git/objects` that are not reachable from any reference. Objects become unreachable when commits are amended, rebased away, branches deleted, or stashes dropped, leaving dangling content in the object database.The command is normally invoked indirectly through git gc, which sets an appropriate --expire time (the `gc.pruneExpire` config, defaulting to `2.weeks.ago`) so that very recent objects are kept around for safety. The expiry window protects concurrent operations and recently created objects that the reflog has not yet started referencing.Note that git prune only touches loose objects. Unreachable objects already inside a packfile are removed by git repack -A.
PARAMETERS
-n, --dry-run
Do not remove anything, just report what would be removed.-v, --verbose
Report all removed objects.--progress
Show progress while pruning.--expire time
Only prune loose objects older than time (e.g. `now`, `2.weeks.ago`).--
Treat the remaining arguments as heads rather than options.heads
Additional refs whose reachable objects should be kept, in addition to all packed refs.
CAVEATS
Aggressive expiry (`--expire=now`) can delete objects that are still useful for recovery via the reflog or that another git process is currently writing. Do not run prune manually while other git commands are running in the same repository. To prune stale worktree metadata under `.git/worktrees`, use git worktree prune instead.
HISTORY
git prune is one of the original plumbing commands shipped with Git. Its day-to-day role has shifted toward being an internal step of git gc, but it remains useful for explicit cleanup after large rewrite operations.
SEE ALSO
git-gc(1), git-fsck(1), git-reflog(1)
