Home Explore Blog CI



git

6th chunk of `Documentation/git-maintenance.adoc`
012f32e22116a4b7cd6f0f9cf169b600f0c32bc1ded4bb4a0000000100000989
 user-scheduled tasks can be found
by running `systemctl --user list-timers`. The timers written by `git
maintenance start` are similar to this:

-----------------------------------------------------------------------
$ systemctl --user list-timers
NEXT                         LEFT          LAST                         PASSED     UNIT                         ACTIVATES
Thu 2021-04-29 19:00:00 CEST 42min left    Thu 2021-04-29 18:00:11 CEST 17min ago  git-maintenance@hourly.timer git-maintenance@hourly.service
Fri 2021-04-30 00:00:00 CEST 5h 42min left Thu 2021-04-29 00:00:11 CEST 18h ago    git-maintenance@daily.timer  git-maintenance@daily.service
Mon 2021-05-03 00:00:00 CEST 3 days left   Mon 2021-04-26 00:00:11 CEST 3 days ago git-maintenance@weekly.timer git-maintenance@weekly.service
-----------------------------------------------------------------------

One timer is registered for each `--schedule=<frequency>` option.

The definition of the systemd units can be inspected in the following files:

-----------------------------------------------------------------------
~/.config/systemd/user/git-maintenance@.timer
~/.config/systemd/user/git-maintenance@.service
~/.config/systemd/user/timers.target.wants/git-maintenance@hourly.timer
~/.config/systemd/user/timers.target.wants/git-maintenance@daily.timer
~/.config/systemd/user/timers.target.wants/git-maintenance@weekly.timer
-----------------------------------------------------------------------

`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)`

Title: Configuring Git Maintenance Schedules on Linux and MacOS
Summary
Git maintenance schedules can be managed using systemd timers on Linux and launchctl on MacOS, with the git maintenance start command creating and starting timers, and git maintenance stop stopping and deleting them, and users can customize schedules by creating drop-in files or using the launchctl tool.