git maintenance

Scheduling Maintenance with git maintenance

git gc --auto runs after some commands once loose objects pile up, and then repacks everything while you wait. git maintenance splits that work into small tasks and runs them in the background on a schedule:

Running two tasks now, then scheduling maintenance with systemd timersShell
git maintenance run --task=commit-graph --task=loose-objects
git maintenance start --scheduler=systemd-timer
git config list --show-scope | grep maintenance
systemctl --user list-unit-files "git-maintenance@*" --no-pager
Output
...
global  maintenance.repo=/home/dev/v5-ch2/booknest
local   maintenance.auto=false
local   maintenance.strategy=incremental
UNIT FILE                    STATE   PRESET
...
git-maintenance@daily.timer  enabled enabled
git-maintenance@hourly.timer enabled enabled
git-maintenance@weekly.timer enabled enabled
...

start added the repository to the global maintenance.repo list, turned off gc --auto for it, chose the incremental strategy and installed three systemd 142,543 user timers, each running git for-each-repo over the list. Incremental maintenance prefetches from remotes (into refs/prefetch/, so your remote-tracking branches never move unexpectedly) and updates the commit-graph hourly, packs loose objects and small packs daily, and packs refs weekly. macOS uses launchctl, Windows the Task Scheduler, others cron. For a manual git maintenance run, Git 2.54 1,932 made the geometric strategy the default: it merges packs so their sizes form a geometric progression instead of repacking everything. git maintenance stop removes the timers, and unregister removes the repository from the list.