By admin , 29 April 2026

Why maintenance, not gc

git maintenance (Git 2.31+) is the modern, task-oriented replacement for gc --auto. It runs specific tasks (commit-graph, prefetch, incremental-repack, loose-objects, pack-refs, gc) on schedules tuned for each, in the background, without blocking your interactive commands.

Starting

git maintenance start
git maintenance start --scheduler=systemd
git maintenance start --scheduler=launchctl
git maintenance start --scheduler=schtasks

Git auto-detects your platform's scheduler and registers entries that run at hourly, daily, and weekly cadences for the appropriate tasks.

Inspecting and stopping

git maintenance status
git maintenance stop
git maintenance unregister

unregister removes the repo from the global maintenance list without stopping the scheduler globally.

Tasks and schedules

TaskDefault scheduleWhat it does
commit-graphhourlyUpdates the commit-graph
prefetchhourlyFetches into hidden refs
loose-objectsdailyPacks loose objects
incremental-repackdailyGeometric repack + MIDX
pack-refsweeklyPacks loose refs
gcoff by defaultFull gc; prefer the others

Manual runs

git maintenance run --task=commit-graph
git maintenance run --task=incremental-repack
git maintenance run --auto                 # threshold-driven

Per-task config

[maintenance]
auto = false
strategy = incremental
[maintenance "commit-graph"]
enabled = true
[maintenance "incremental-repack"]
enabled = true
auto = 100      # # of new packs to trigger
[maintenance "loose-objects"]
enabled = true
batchSize = 50

Disabling auto-gc

When using maintenance, disable the legacy auto-gc so they do not fight:

git config gc.auto 0

Common mistakes

Forgetting to git maintenance start after cloning a large repo — performance features grow stale. Running maintenance and traditional gc together. Setting maintenance.auto=false globally without a replacement schedule.

Logs

Maintenance logs to the platform's scheduler facility. On systemd: journalctl --user -u git-maintenance.service. On macOS: ~/Library/Logs/git-maintenance.log.

Related

See "Git garbage collection: gc, prune, and pack-refs", "Geometric repacking strategy", and "The commit-graph: faster reachability queries".