2.0 KiB
⬅️ Back to Git Essentials & Hidden Gems
git maintenance start
Runs a cronJob in background for the specified repo for periodic maintenance.
git maintenance start enables background maintenance tasks for your Git repository. It sets up scheduled jobs (using your system’s scheduler, like cron on Unix or Task Scheduler on Windows) to automatically run Git maintenance commands at regular intervals. This keeps your repository fast and healthy by running tasks like garbage collection, commit-graph optimization, and cleanup operations in the background, so you don’t have to remember to do it manually.
Command
git maintenance start
Examples
- Enable background maintenance for your repository.
git maintenance start
- Run maintenance tasks every hour for more active repos.
git maintenance start --schedule=hourly
Steps
- Run
git maintenance startin your repository. - Optionally, use
--schedule=hourlyor--schedule=dailyto control how often maintenance runs. Git will now automatically run tasks like garbage collection, pruning unreachable objects, and optimizing internal data structures in the background.- You can stop background maintenance with
git maintenance stopif needed.
ProTips
Tip
Set up maintenance on large or long-lived repos to keep them fast and healthy.
Tip
Use with cron or scheduled tasks for automation.
Tip
If you notice Git getting slow, check if maintenance is enabled or run it manually.
Links
➡️ See the Next Step: git request-pull
Author: mike-rambil • Updated: 2024-06-10 • Tags: maintenance, automation