# info > GIT-MAINTENANCE

---
type: CommandReference
command: git-maintenance
mode: man
section: "1"
source: man-pages
---

## Quick Reference
- `git maintenance run --task=gc` — Run garbage collection
- `git maintenance run --auto` — Run tasks only if thresholds are met
- `git maintenance register` — Enable background maintenance for this repo
- `git maintenance start` — Start scheduled background maintenance
- `git maintenance stop` — Stop background maintenance schedule
- `git maintenance unregister` — Remove repo from background maintenance list
- `git maintenance run --task=prefetch` — Fetch latest objects for all remotes in background
- `git maintenance run --task=commit-graph` — Update commit-graph incrementally

## Name
`git-maintenance` — Run tasks to optimize Git repository data

## Synopsis
shell
git maintenance run [--auto] [--schedule] [--quiet] [--task=<task>...]
git maintenance register
git maintenance start [--scheduler=<scheduler>]
git maintenance stop
git maintenance unregister
## Options
### `run` subcommand options
- `--auto` — Run tasks only if specified thresholds are met (e.g., number of loose objects exceeds `gc.auto`). Not compatible with `--schedule`.
- `--schedule` — Run tasks only if the elapsed time since the last run meets the `maintenance.<task>.schedule` config value. Cannot be combined with `--auto`.
- `--quiet` — Suppress progress output to stderr.
- `--task=<task>` — Specify one or more tasks to run in the given order. If omitted, tasks with `maintenance.<task>.enabled` set to `true` are run. Valid tasks:

    - `commit-graph` — Incrementally update the commit-graph and verify correctness. Safe to run concurrently.
    - `prefetch` — Fetch latest objects from all remotes into `refs/prefetch/` without updating remote-tracking branches. Speeds up subsequent fetches.
    - `gc` — Full garbage collection: repack objects, prune stale data. Expensive; may be disruptive. See [git-gc(1)](http://localhost/phpMan.php/man/git-gc/1/markdown).
    - `loose-objects` — Delete loose objects already in a pack, then pack remaining loose objects (batch size ≤50k). Not recommended alongside `gc` due to conflict.
    - `incremental-repack` — Repack small pack-files using the multi-pack-index. Default batch-size=0 repacks all into one pack. See [git-multi-pack-index(1)](http://localhost/phpMan.php/man/git-multi-pack-index/1/markdown).
    - `pack-refs` — Collect loose refs into a single file for faster reference iteration. See [git-pack-refs(1)](http://localhost/phpMan.php/man/git-pack-refs/1/markdown).

### `start` subcommand option
- `--scheduler=<scheduler>` — Choose the background scheduler for periodic execution. Possible values: `auto` (platform default), `crontab` (POSIX), `systemd-timer` (Linux), `launchctl` (macOS), `schtasks` (Windows). Default is `auto`.

## Examples
shell
# Run only garbage collection
git maintenance run --task=gc

# Run maintenance tasks based on internal thresholds
git maintenance run --auto

# Register the current repository for background maintenance
git maintenance register

# Start background maintenance with systemd timers
git maintenance start --scheduler=systemd-timer

# Stop background maintenance without unregistering
git maintenance stop

# Remove the repository from the background maintenance list
git maintenance unregister
## See Also
- [git(1)](http://localhost/phpMan.php/man/git/1/markdown)
- [git-gc(1)](http://localhost/phpMan.php/man/git-gc/1/markdown)
- [git-multi-pack-index(1)](http://localhost/phpMan.php/man/git-multi-pack-index/1/markdown)
- [git-pack-refs(1)](http://localhost/phpMan.php/man/git-pack-refs/1/markdown)
- [git-for-each-repo(1)](http://localhost/phpMan.php/man/git-for-each-repo/1/markdown)
- [cron(8)](http://localhost/phpMan.php/man/cron/8/markdown)
- [crontab(5)](http://localhost/phpMan.php/man/crontab/5/markdown)
- [systemd.timer(5)](http://localhost/phpMan.php/man/systemd.timer/5/markdown)
- [launchctl.plist(5)](http://localhost/phpMan.php/man/launchctl.plist/5/markdown)