LinuxCommandLibrary

git-prune

TLDR

Prune unreachable objects

$ git prune
copy
Dry run
$ git prune -n
copy
Prune verbose
$ git prune -v
copy
Prune older than date
$ git prune --expire [2.weeks.ago]
copy

SYNOPSIS

git prune [options]

DESCRIPTION

git prune removes unreachable objects from the object database. Objects become unreachable when their referencing commits are deleted or rebased away.
The command is typically run as part of git gc. Direct use is for specific cleanup scenarios. Expire times prevent pruning recent objects that might still be needed.
git prune cleans up orphaned repository objects.

PARAMETERS

-n, --dry-run

Show what would be removed.
-v, --verbose
Report removed objects.
--expire DATE
Only prune older than date.
--progress
Show progress.
--help
Display help information.

CAVEATS

Usually run by git gc. Can delete objects needed by concurrent operations. Use expire time for safety.

HISTORY

git prune is a core Git maintenance command for removing unreachable objects, typically invoked through git gc.

SEE ALSO

Copied to clipboard