{
    "content": [
        {
            "type": "text",
            "text": "# GIT-MAINTENANCE (man)\n\n## NAME\n\ngit-maintenance - Run tasks to optimize Git repository data\n\n## SYNOPSIS\n\ngit maintenance run [<options>]\n\n## DESCRIPTION\n\nRun tasks to optimize Git repository data, speeding up other Git commands and reducing\nstorage requirements for the repository.\n\n## TLDR\n\n> Run tasks to optimize Git repository data.\n\n- Register the current repository in the user's list of repositories to daily have maintenance run:\n  `git maintenance register`\n- Schedule maintenance tasks to run on the current repository every hour:\n  `git maintenance start`\n- Halt the background maintenance schedule for the current repository:\n  `git maintenance stop`\n- Remove the current repository from the user's maintenance repository list:\n  `git maintenance unregister`\n- Run a specific maintenance task on the current repository:\n  `git maintenance run --task {{commit-graph|gc|incremental-repack|loose-objects|pack-refs|prefetch}}`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **SUBCOMMANDS**\n- **TASKS**\n- **OPTIONS** (3 subsections)\n- **TROUBLESHOOTING**\n- **BACKGROUND MAINTENANCE ON POSIX SYSTEMS**\n- **BACKGROUND MAINTENANCE ON LINUX SYSTEMD SYSTEMS**\n- **BACKGROUND MAINTENANCE ON MACOS SYSTEMS**\n- **BACKGROUND MAINTENANCE ON WINDOWS SYSTEMS**\n- **GIT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "GIT-MAINTENANCE",
        "section": "",
        "mode": "man",
        "summary": "git-maintenance - Run tasks to optimize Git repository data",
        "synopsis": "git maintenance run [<options>]",
        "tldr_summary": "Run tasks to optimize Git repository data.",
        "tldr_examples": [
            {
                "description": "Register the current repository in the user's list of repositories to daily have maintenance run",
                "command": "git maintenance register"
            },
            {
                "description": "Schedule maintenance tasks to run on the current repository every hour",
                "command": "git maintenance start"
            },
            {
                "description": "Halt the background maintenance schedule for the current repository",
                "command": "git maintenance stop"
            },
            {
                "description": "Remove the current repository from the user's maintenance repository list",
                "command": "git maintenance unregister"
            },
            {
                "description": "Run a specific maintenance task on the current repository",
                "command": "git maintenance run --task {{commit-graph|gc|incremental-repack|loose-objects|pack-refs|prefetch}}"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "",
                "long": "--auto",
                "arg": null,
                "description": "When combined with the run subcommand, run maintenance tasks only if certain thresholds are met. For example, the gc task runs when the number of loose objects exceeds the number stored in the gc.auto config setting, or when the number of pack-files exceeds the gc.autoPackLimit config setting. Not compatible with the --schedule option."
            },
            {
                "flag": "",
                "long": "--schedule",
                "arg": null,
                "description": "When combined with the run subcommand, run maintenance tasks only if certain time conditions are met, as specified by the maintenance.<task>.schedule config value for each <task>. This config value specifies a number of seconds since the last time that task ran, according to the maintenance.<task>.lastRun config value. The tasks that are tested are those provided by the --task=<task> option(s) or those with maintenance.<task>.enabled set to true."
            },
            {
                "flag": "",
                "long": "--quiet",
                "arg": null,
                "description": "Do not report progress or other information over stderr. --task=<task> If this option is specified one or more times, then only run the specified tasks in the specified order. If no --task=<task> arguments are specified, then only the tasks with maintenance.<task>.enabled configured as true are considered. See the TASKS section for the list of accepted <task> values. --scheduler=auto|crontab|systemd-timer|launchctl|schtasks When combined with the start subcommand, specify the scheduler for running the hourly, daily and weekly executions of git maintenance run. Possible values for <scheduler> are auto, crontab (POSIX), systemd-timer (Linux), launchctl (macOS), and schtasks (Windows). When auto is specified, the appropriate platform-specific scheduler is used; on Linux, systemd-timer is used if available, otherwise crontab. Default is auto."
            }
        ],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "SUBCOMMANDS",
                "lines": 45,
                "subsections": []
            },
            {
                "name": "TASKS",
                "lines": 56,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "--auto",
                        "lines": 5,
                        "long": "--auto"
                    },
                    {
                        "name": "--schedule",
                        "lines": 7,
                        "long": "--schedule"
                    },
                    {
                        "name": "--quiet",
                        "lines": 15,
                        "long": "--quiet"
                    }
                ]
            },
            {
                "name": "TROUBLESHOOTING",
                "lines": 35,
                "subsections": []
            },
            {
                "name": "BACKGROUND MAINTENANCE ON POSIX SYSTEMS",
                "lines": 41,
                "subsections": []
            },
            {
                "name": "BACKGROUND MAINTENANCE ON LINUX SYSTEMD SYSTEMS",
                "lines": 35,
                "subsections": []
            },
            {
                "name": "BACKGROUND MAINTENANCE ON MACOS SYSTEMS",
                "lines": 31,
                "subsections": []
            },
            {
                "name": "BACKGROUND MAINTENANCE ON WINDOWS SYSTEMS",
                "lines": 15,
                "subsections": []
            },
            {
                "name": "GIT",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "git-maintenance - Run tasks to optimize Git repository data\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "git maintenance run [<options>]\n\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Run tasks to optimize Git repository data, speeding up other Git commands and reducing\nstorage requirements for the repository.\n\nGit commands that add repository data, such as git add or git fetch, are optimized for a\nresponsive user experience. These commands do not take time to optimize the Git data, since\nsuch optimizations scale with the full size of the repository while these user commands each\nperform a relatively small action.\n\nThe git maintenance command provides flexibility for how to optimize the Git repository.\n",
                "subsections": []
            },
            "SUBCOMMANDS": {
                "content": "register\nInitialize Git config values so any scheduled maintenance will start running on this\nrepository. This adds the repository to the maintenance.repo config variable in the\ncurrent user’s global config and enables some recommended configuration values for\nmaintenance.<task>.schedule. The tasks that are enabled are safe for running in the\nbackground without disrupting foreground processes.\n\nThe register subcommand will also set the maintenance.strategy config value to\nincremental, if this value is not previously set. The incremental strategy uses the\nfollowing schedule for each maintenance task:\n\n•   gc: disabled.\n\n•   commit-graph: hourly.\n\n•   prefetch: hourly.\n\n•   loose-objects: daily.\n\n•   incremental-repack: daily.\n\ngit maintenance register will also disable foreground maintenance by setting\nmaintenance.auto = false in the current repository. This config setting will remain after\na git maintenance unregister command.\n\nrun\nRun one or more maintenance tasks. If one or more --task options are specified, then\nthose tasks are run in that order. Otherwise, the tasks are determined by which\nmaintenance.<task>.enabled config options are true. By default, only\nmaintenance.gc.enabled is true.\n\nstart\nStart running maintenance on the current repository. This performs the same config\nupdates as the register subcommand, then updates the background scheduler to run git\nmaintenance run --scheduled on an hourly basis.\n\nstop\nHalt the background maintenance schedule. The current repository is not removed from the\nlist of maintained repositories, in case the background maintenance is restarted later.\n\nunregister\nRemove the current repository from background maintenance. This only removes the\nrepository from the configured list. It does not stop the background maintenance\nprocesses from running.\n",
                "subsections": []
            },
            "TASKS": {
                "content": "commit-graph\nThe commit-graph job updates the commit-graph files incrementally, then verifies that the\nwritten data is correct. The incremental write is safe to run alongside concurrent Git\nprocesses since it will not expire .graph files that were in the previous\ncommit-graph-chain file. They will be deleted by a later run based on the expiration\ndelay.\n\nprefetch\nThe prefetch task updates the object directory with the latest objects from all\nregistered remotes. For each remote, a git fetch command is run. The configured refspec\nis modified to place all requested refs within refs/prefetch/. Also, tags are not\nupdated.\n\nThis is done to avoid disrupting the remote-tracking branches. The end users expect these\nrefs to stay unmoved unless they initiate a fetch. With prefetch task, however, the\nobjects necessary to complete a later real fetch would already be obtained, so the real\nfetch would go faster. In the ideal case, it will just become an update to a bunch of\nremote-tracking branches without any object transfer.\n\ngc\nClean up unnecessary files and optimize the local repository. \"GC\" stands for \"garbage\ncollection,\" but this task performs many smaller tasks. This task can be expensive for\nlarge repositories, as it repacks all Git objects into a single pack-file. It can also be\ndisruptive in some situations, as it deletes stale data. See git-gc(1) for more details\non garbage collection in Git.\n\nloose-objects\nThe loose-objects job cleans up loose objects and places them into pack-files. In order\nto prevent race conditions with concurrent Git commands, it follows a two-step process.\nFirst, it deletes any loose objects that already exist in a pack-file; concurrent Git\nprocesses will examine the pack-file for the object data instead of the loose object.\nSecond, it creates a new pack-file (starting with \"loose-\") containing a batch of loose\nobjects. The batch size is limited to 50 thousand objects to prevent the job from taking\ntoo long on a repository with many loose objects. The gc task writes unreachable objects\nas loose objects to be cleaned up by a later step only if they are not re-added to a\npack-file; for this reason it is not advisable to enable both the loose-objects and gc\ntasks at the same time.\n\nincremental-repack\nThe incremental-repack job repacks the object directory using the multi-pack-index\nfeature. In order to prevent race conditions with concurrent Git commands, it follows a\ntwo-step process. First, it calls git multi-pack-index expire to delete pack-files\nunreferenced by the multi-pack-index file. Second, it calls git multi-pack-index repack\nto select several small pack-files and repack them into a bigger one, and then update the\nmulti-pack-index entries that refer to the small pack-files to refer to the new\npack-file. This prepares those small pack-files for deletion upon the next run of git\nmulti-pack-index expire. The selection of the small pack-files is such that the expected\nsize of the big pack-file is at least the batch size; see the --batch-size option for the\nrepack subcommand in git-multi-pack-index(1). The default batch-size is zero, which is a\nspecial case that attempts to repack all pack-files into a single pack-file.\n\npack-refs\nThe pack-refs task collects the loose reference files and collects them into a single\nfile. This speeds up operations that need to iterate across many references. See git-\npack-refs(1) for more information.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "",
                "subsections": [
                    {
                        "name": "--auto",
                        "content": "When combined with the run subcommand, run maintenance tasks only if certain thresholds\nare met. For example, the gc task runs when the number of loose objects exceeds the\nnumber stored in the gc.auto config setting, or when the number of pack-files exceeds the\ngc.autoPackLimit config setting. Not compatible with the --schedule option.\n",
                        "long": "--auto"
                    },
                    {
                        "name": "--schedule",
                        "content": "When combined with the run subcommand, run maintenance tasks only if certain time\nconditions are met, as specified by the maintenance.<task>.schedule config value for each\n<task>. This config value specifies a number of seconds since the last time that task\nran, according to the maintenance.<task>.lastRun config value. The tasks that are tested\nare those provided by the --task=<task> option(s) or those with\nmaintenance.<task>.enabled set to true.\n",
                        "long": "--schedule"
                    },
                    {
                        "name": "--quiet",
                        "content": "Do not report progress or other information over stderr.\n\n--task=<task>\nIf this option is specified one or more times, then only run the specified tasks in the\nspecified order. If no --task=<task> arguments are specified, then only the tasks with\nmaintenance.<task>.enabled configured as true are considered. See the TASKS section for\nthe list of accepted <task> values.\n\n--scheduler=auto|crontab|systemd-timer|launchctl|schtasks\nWhen combined with the start subcommand, specify the scheduler for running the hourly,\ndaily and weekly executions of git maintenance run. Possible values for <scheduler> are\nauto, crontab (POSIX), systemd-timer (Linux), launchctl (macOS), and schtasks (Windows).\nWhen auto is specified, the appropriate platform-specific scheduler is used; on Linux,\nsystemd-timer is used if available, otherwise crontab. Default is auto.\n",
                        "long": "--quiet"
                    }
                ]
            },
            "TROUBLESHOOTING": {
                "content": "The git maintenance command is designed to simplify the repository maintenance patterns while\nminimizing user wait time during Git commands. A variety of configuration options are\navailable to allow customizing this process. The default maintenance options focus on\noperations that complete quickly, even on large repositories.\n\nUsers may find some cases where scheduled maintenance tasks do not run as frequently as\nintended. Each git maintenance run command takes a lock on the repository’s object database,\nand this prevents other concurrent git maintenance run commands from running on the same\nrepository. Without this safeguard, competing processes could leave the repository in an\nunpredictable state.\n\nThe background maintenance schedule runs git maintenance run processes on an hourly basis.\nEach run executes the \"hourly\" tasks. At midnight, that process also executes the \"daily\"\ntasks. At midnight on the first day of the week, that process also executes the \"weekly\"\ntasks. A single process iterates over each registered repository, performing the scheduled\ntasks for that frequency. Depending on the number of registered repositories and their sizes,\nthis process may take longer than an hour. In this case, multiple git maintenance run\ncommands may run on the same repository at the same time, colliding on the object database\nlock. This results in one of the two tasks not running.\n\nIf you find that some maintenance windows are taking longer than one hour to complete, then\nconsider reducing the complexity of your maintenance tasks. For example, the gc task is much\nslower than the incremental-repack task. However, this comes at a cost of a slightly larger\nobject database. Consider moving more expensive tasks to be run less frequently.\n\nExpert users may consider scheduling their own maintenance tasks using a different schedule\nthan is available through git maintenance start and Git configuration options. These users\nshould be aware of the object database lock and how concurrent git maintenance run commands\nbehave. Further, the git gc command should not be combined with git maintenance run commands.\ngit gc modifies the object database but does not take the lock in the same way as git\nmaintenance run. If possible, use git maintenance run --task=gc instead of git gc.\n\nThe following sections describe the mechanisms put in place to run background maintenance by\ngit maintenance start and how to customize them.\n",
                "subsections": []
            },
            "BACKGROUND MAINTENANCE ON POSIX SYSTEMS": {
                "content": "The standard mechanism for scheduling background tasks on POSIX systems is cron(8). This tool\nexecutes commands based on a given schedule. The current list of user-scheduled tasks can be\nfound by running crontab -l. The schedule written by git maintenance start is similar to\nthis:\n\n# BEGIN GIT MAINTENANCE SCHEDULE\n# The following schedule was created by Git\n# Any edits made in this region might be\n# replaced in the future by a Git command.\n\n0 1-23 * * * \"/<path>/git\" --exec-path=\"/<path>\" for-each-repo --config=maintenance.repo maintenance run --schedule=hourly\n0 0 * * 1-6 \"/<path>/git\" --exec-path=\"/<path>\" for-each-repo --config=maintenance.repo maintenance run --schedule=daily\n0 0 * * 0 \"/<path>/git\" --exec-path=\"/<path>\" for-each-repo --config=maintenance.repo maintenance run --schedule=weekly\n\n# END GIT MAINTENANCE SCHEDULE\n\n\nThe comments are used as a region to mark the schedule as written by Git. Any modifications\nwithin this region will be completely deleted by git maintenance stop or overwritten by git\nmaintenance start.\n\nThe crontab entry specifies the full path of the git executable to ensure that the executed\ngit command is the same one with which git maintenance start was issued independent of PATH.\nIf the same user runs git maintenance start with multiple Git executables, then only the\nlatest executable is used.\n\nThese commands use git for-each-repo --config=maintenance.repo to run git maintenance run\n--schedule=<frequency> on each repository listed in the multi-valued maintenance.repo config\noption. These are typically loaded from the user-specific global config. The git maintenance\nprocess then determines which maintenance tasks are configured to run on each repository with\neach <frequency> using the maintenance.<task>.schedule config options. These values are\nloaded from the global or repository config values.\n\nIf the config values are insufficient to achieve your desired background maintenance\nschedule, then you can create your own schedule. If you run crontab -e, then an editor will\nload with your user-specific cron schedule. In that editor, you can add your own schedule\nlines. You could start by adapting the default schedule listed earlier, or you could read the\ncrontab(5) documentation for advanced scheduling techniques. Please do use the full path and\n--exec-path techniques from the default schedule to ensure you are executing the correct\nbinaries in your schedule.\n",
                "subsections": []
            },
            "BACKGROUND MAINTENANCE ON LINUX SYSTEMD SYSTEMS": {
                "content": "While Linux supports cron, depending on the distribution, cron may be an optional package not\nnecessarily installed. On modern Linux distributions, systemd timers are superseding it.\n\nIf user systemd timers are available, they will be used as a replacement of cron.\n\nIn this case, git maintenance start will create user systemd timer units and start the\ntimers. The current list of user-scheduled tasks can be found by running systemctl --user\nlist-timers. The timers written by git maintenance start are similar to this:\n\n$ systemctl --user list-timers\nNEXT                         LEFT          LAST                         PASSED     UNIT                         ACTIVATES\nThu 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\nFri 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\nMon 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\n\n\nOne timer is registered for each --schedule=<frequency> option.\n\nThe definition of the systemd units can be inspected in the following files:\n\n~/.config/systemd/user/git-maintenance@.timer\n~/.config/systemd/user/git-maintenance@.service\n~/.config/systemd/user/timers.target.wants/git-maintenance@hourly.timer\n~/.config/systemd/user/timers.target.wants/git-maintenance@daily.timer\n~/.config/systemd/user/timers.target.wants/git-maintenance@weekly.timer\n\n\ngit maintenance start will overwrite these files and start the timer again with systemctl\n--user, so any customization should be done by creating a drop-in file, i.e. a .conf suffixed\nfile in the ~/.config/systemd/user/git-maintenance@.service.d directory.\n\ngit maintenance stop will stop the user systemd timers and delete the above mentioned files.\n\nFor more details, see systemd.timer(5).\n",
                "subsections": []
            },
            "BACKGROUND MAINTENANCE ON MACOS SYSTEMS": {
                "content": "While macOS technically supports cron, using crontab -e requires elevated privileges and the\nexecuted process does not have a full user context. Without a full user context, Git and its\ncredential helpers cannot access stored credentials, so some maintenance tasks are not\nfunctional.\n\nInstead, git maintenance start interacts with the launchctl tool, which is the recommended\nway to schedule timed jobs in macOS. Scheduling maintenance through git maintenance\n(start|stop) requires some launchctl features available only in macOS 10.11 or later.\n\nYour user-specific scheduled tasks are stored as XML-formatted .plist files in\n~/Library/LaunchAgents/. You can see the currently-registered tasks using the following\ncommand:\n\n$ ls ~/Library/LaunchAgents/org.git-scm.git*\norg.git-scm.git.daily.plist\norg.git-scm.git.hourly.plist\norg.git-scm.git.weekly.plist\n\n\nOne task is registered for each --schedule=<frequency> option. To inspect how the XML format\ndescribes each schedule, open one of these .plist files in an editor and inspect the <array>\nelement following the <key>StartCalendarInterval</key> element.\n\ngit maintenance start will overwrite these files and register the tasks again with launchctl,\nso any customizations should be done by creating your own .plist files with distinct names.\nSimilarly, the git maintenance stop command will unregister the tasks with launchctl and\ndelete the .plist files.\n\nTo create more advanced customizations to your background tasks, see launchctl.plist(5) for\nmore information.\n",
                "subsections": []
            },
            "BACKGROUND MAINTENANCE ON WINDOWS SYSTEMS": {
                "content": "Windows does not support cron and instead has its own system for scheduling background tasks.\nThe git maintenance start command uses the schtasks command to submit tasks to this system.\nYou can inspect all background tasks using the Task Scheduler application. The tasks added by\nGit have names of the form Git Maintenance (<frequency>). The Task Scheduler GUI has ways to\ninspect these tasks, but you can also export the tasks to XML files and view the details\nthere.\n\nNote that since Git is a console application, these background tasks create a console window\nvisible to the current user. This can be changed manually by selecting the \"Run whether user\nis logged in or not\" option in Task Scheduler. This change requires a password input, which\nis why git maintenance start does not select it by default.\n\nIf you want to customize the background tasks, please rename the tasks so future calls to git\nmaintenance (start|stop) do not overwrite your custom tasks.\n",
                "subsections": []
            },
            "GIT": {
                "content": "Part of the git(1) suite\n\n\n\nGit 2.34.1                                   02/26/2026                           GIT-MAINTENANCE(1)",
                "subsections": []
            }
        }
    }
}