Perche maintenance, non gc
git maintenance (Git 2.31+) e il moderno sostituto orientato ai task di gc --auto. Esegue task specifici (commit-graph, prefetch, incremental-repack, loose-objects, pack-refs, gc) su schedulazioni ottimizzate per ognuno, in background, senza bloccare i comandi interattivi.
Avvio
git maintenance start
git maintenance start --scheduler=systemd
git maintenance start --scheduler=launchctl
git maintenance start --scheduler=schtasks
Ispezione e arresto
git maintenance status
git maintenance stop
git maintenance unregister
Task e schedulazioni
| Task | Schedule predefinito | Cosa fa |
|---|---|---|
| commit-graph | orario | Aggiorna il commit-graph |
| prefetch | orario | Fetch in ref nascosti |
| loose-objects | giornaliero | Ripacka oggetti loose |
| incremental-repack | giornaliero | Repack geometrico + MIDX |
| pack-refs | settimanale | Impacchetta i ref loose |
| gc | off per default | gc completo |
Esecuzioni manuali
git maintenance run --task=commit-graph
git maintenance run --task=incremental-repack
git maintenance run --auto
Configurazione per task
[maintenance]
auto = false
strategy = incremental
[maintenance "commit-graph"]
enabled = true
[maintenance "incremental-repack"]
enabled = true
auto = 100
[maintenance "loose-objects"]
enabled = true
batchSize = 50
Disabilitare auto-gc
git config gc.auto 0
Errori comuni
Dimenticare di git maintenance start dopo aver clonato un repo grande.
Log
Su systemd: journalctl --user -u git-maintenance.service. Su macOS: ~/Library/Logs/git-maintenance.log.