LinuxCommandLibrary

git-gc

Cleanup and optimize repository storage

TLDR

Run garbage collection

$ git gc
copy
Aggressive cleanup
$ git gc --aggressive
copy
Prune immediately
$ git gc --prune=now
copy
Auto gc if needed
$ git gc --auto
copy
Quiet mode
$ git gc --quiet
copy

SYNOPSIS

git gc [options]

DESCRIPTION

git gc (garbage collection) cleans up unnecessary files and optimizes the repository. It packs loose objects, removes unreachable objects, and compresses the repository for better performance.
Git runs gc automatically after certain operations. Manual gc is useful after history rewrites or large imports. Aggressive mode performs deeper optimization but takes significantly longer.

PARAMETERS

--aggressive

More thorough optimization (slow).
--prune DATE
Prune objects older than date.
--auto
Only run if needed.
--quiet
Suppress output.
--force
Force gc even if another running.
--help
Display help information.

CAVEATS

Aggressive is slow. Running gc removes dangling objects. Let gc complete before other operations.

HISTORY

git gc is a core Git command for repository maintenance, automating cleanup tasks that were originally separate commands.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community