Home Explore Blog CI



git

7th chunk of `Documentation/git-maintenance.adoc`
7b993d86c1c445d978ddf5e37e70c03176a321860a0c1dc00000000100000d98

-----------------------------------------------------------------------

`git maintenance start` will overwrite these files and start the timer
again with `systemctl --user`, so any customization should be done by
creating a drop-in file, i.e. a `.conf` suffixed file in the
`~/.config/systemd/user/git-maintenance@.service.d` directory.

`git maintenance stop` will stop the user systemd timers and delete
the above mentioned files.

For more details, see `systemd.timer(5)`.


BACKGROUND MAINTENANCE ON MACOS SYSTEMS
---------------------------------------

While macOS technically supports `cron`, using `crontab -e` requires
elevated privileges and the executed process does not have a full user
context. Without a full user context, Git and its credential helpers
cannot access stored credentials, so some maintenance tasks are not
functional.

Instead, `git maintenance start` interacts with the `launchctl` tool,
which is the recommended way to schedule timed jobs in macOS. Scheduling
maintenance through `git maintenance (start|stop)` requires some
`launchctl` features available only in macOS 10.11 or later.

Your user-specific scheduled tasks are stored as XML-formatted `.plist`
files in `~/Library/LaunchAgents/`. You can see the currently-registered
tasks using the following command:

-----------------------------------------------------------------------
$ ls ~/Library/LaunchAgents/org.git-scm.git*
org.git-scm.git.daily.plist
org.git-scm.git.hourly.plist
org.git-scm.git.weekly.plist
-----------------------------------------------------------------------

One task is registered for each `--schedule=<frequency>` option. To
inspect how the XML format describes each schedule, open one of these
`.plist` files in an editor and inspect the `<array>` element following
the `<key>StartCalendarInterval</key>` element.

`git maintenance start` will overwrite these files and register the
tasks again with `launchctl`, so any customizations should be done by
creating your own `.plist` files with distinct names. Similarly, the
`git maintenance stop` command will unregister the tasks with `launchctl`
and delete the `.plist` files.

To create more advanced customizations to your background tasks, see
launchctl.plist(5) for more information.


BACKGROUND MAINTENANCE ON WINDOWS SYSTEMS
-----------------------------------------

Windows does not support `cron` and instead has its own system for
scheduling background tasks. The `git maintenance start` command uses
the `schtasks` command to submit tasks to this system. You can inspect
all background tasks using the Task Scheduler application. The tasks
added by Git have names of the form `Git Maintenance (<frequency>)`.
The Task Scheduler GUI has ways to inspect these tasks, but you can also
export the tasks to XML files and view the details there.

Note that since Git is a console application, these background tasks
create a console window visible to the current user. This can be changed
manually by selecting the "Run whether user is logged in or not" option
in Task Scheduler. This change requires a password input, which is why
`git maintenance start` does not select it by default.

If you want to customize the background tasks, please rename the tasks
so future calls to `git maintenance (start|stop)` do not overwrite your
custom tasks.

CONFIGURATION
-------------

include::includes/cmd-config-section-all.adoc[]

include::config/maintenance.adoc[]


GIT
---
Part of the linkgit:git[1] suite

Title: Configuring Git Background Maintenance on Various Systems
Summary
Git maintenance schedules can be configured on Linux using systemd, on MacOS using launchctl, and on Windows using the Task Scheduler, with each system having its own method for customizing and inspecting background tasks, such as creating drop-in files or editing XML-formatted plist files.