Autogenerated HTML docs for v2.45.0-31-gd4cc1
[git-htmldocs.git] / git-maintenance.html
blob5f08167802f40d790c116d433c78f5fe5e8b867b
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
7 <meta name="generator" content="AsciiDoc 10.2.0" />
8 <title>git-maintenance(1)</title>
9 <style type="text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
12 /* Default font. */
13 body {
14 font-family: Georgia,serif;
17 /* Title font. */
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
21 #toctitle,
22 #author, #revnumber, #revdate, #revremark,
23 #footer {
24 font-family: Arial,Helvetica,sans-serif;
27 body {
28 margin: 1em 5% 1em 5%;
31 a {
32 color: blue;
33 text-decoration: underline;
35 a:visited {
36 color: fuchsia;
39 em {
40 font-style: italic;
41 color: navy;
44 strong {
45 font-weight: bold;
46 color: #083194;
49 h1, h2, h3, h4, h5, h6 {
50 color: #527bbd;
51 margin-top: 1.2em;
52 margin-bottom: 0.5em;
53 line-height: 1.3;
56 h1, h2, h3 {
57 border-bottom: 2px solid silver;
59 h2 {
60 padding-top: 0.5em;
62 h3 {
63 float: left;
65 h3 + * {
66 clear: left;
68 h5 {
69 font-size: 1.0em;
72 div.sectionbody {
73 margin-left: 0;
76 hr {
77 border: 1px solid silver;
80 p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
85 ul, ol, li > p {
86 margin-top: 0;
88 ul > li { color: #aaa; }
89 ul > li > * { color: black; }
91 .monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
95 padding: 0;
96 margin: 0;
98 pre {
99 white-space: pre-wrap;
102 #author {
103 color: #527bbd;
104 font-weight: bold;
105 font-size: 1.1em;
107 #email {
109 #revnumber, #revdate, #revremark {
112 #footer {
113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
118 #footer-text {
119 float: left;
120 padding-bottom: 0.5em;
122 #footer-badges {
123 float: right;
124 padding-bottom: 0.5em;
127 #preamble {
128 margin-top: 1.5em;
129 margin-bottom: 1.5em;
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
134 margin-top: 1.0em;
135 margin-bottom: 1.5em;
137 div.admonitionblock {
138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
144 div.content { /* Block element content. */
145 padding: 0;
148 /* Block element titles. */
149 div.title, caption.title {
150 color: #527bbd;
151 font-weight: bold;
152 text-align: left;
153 margin-top: 1.0em;
154 margin-bottom: 0.5em;
156 div.title + * {
157 margin-top: 0;
160 td div.title:first-child {
161 margin-top: 0.0em;
163 div.content div.title:first-child {
164 margin-top: 0.0em;
166 div.content + div.title {
167 margin-top: 0.0em;
170 div.sidebarblock > div.content {
171 background: #ffffee;
172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
174 padding: 0.5em;
177 div.listingblock > div.content {
178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
181 padding: 0.5em;
184 div.quoteblock, div.verseblock {
185 padding-left: 1.0em;
186 margin-left: 1.0em;
187 margin-right: 10%;
188 border-left: 5px solid #f0f0f0;
189 color: #888;
192 div.quoteblock > div.attribution {
193 padding-top: 0.5em;
194 text-align: right;
197 div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
201 div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
205 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
207 text-align: left;
210 div.admonitionblock .icon {
211 vertical-align: top;
212 font-size: 1.1em;
213 font-weight: bold;
214 text-decoration: underline;
215 color: #527bbd;
216 padding-right: 0.5em;
218 div.admonitionblock td.content {
219 padding-left: 0.5em;
220 border-left: 3px solid #dddddd;
223 div.exampleblock > div.content {
224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
228 div.imageblock div.content { padding-left: 0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
232 dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
236 dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
239 font-style: normal;
240 color: navy;
242 dd > *:first-child {
243 margin-top: 0.1em;
246 ul, ol {
247 list-style-position: outside;
249 ol.arabic {
250 list-style-type: decimal;
252 ol.loweralpha {
253 list-style-type: lower-alpha;
255 ol.upperalpha {
256 list-style-type: upper-alpha;
258 ol.lowerroman {
259 list-style-type: lower-roman;
261 ol.upperroman {
262 list-style-type: upper-roman;
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
268 margin-top: 0.1em;
269 margin-bottom: 0.1em;
272 tfoot {
273 font-weight: bold;
275 td > div.verse {
276 white-space: pre;
279 div.hdlist {
280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
283 div.hdlist tr {
284 padding-bottom: 15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
289 td.hdlist1 {
290 vertical-align: top;
291 font-style: normal;
292 padding-right: 0.8em;
293 color: navy;
295 td.hdlist2 {
296 vertical-align: top;
298 div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
303 .comment {
304 background: yellow;
307 .footnote, .footnoteref {
308 font-size: 0.8em;
311 span.footnote, span.footnoteref {
312 vertical-align: super;
315 #footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
320 #footnotes div.footnote {
321 margin: 0 0 5px 0;
324 #footnotes hr {
325 border: none;
326 border-top: 1px solid silver;
327 height: 1px;
328 text-align: left;
329 margin-left: 0;
330 width: 20%;
331 min-width: 100px;
334 div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
339 div.colist td img {
340 margin-top: 0.3em;
343 @media print {
344 #footer-badges { display: none; }
347 #toc {
348 margin-bottom: 2.5em;
351 #toctitle {
352 color: #527bbd;
353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
360 margin-top: 0;
361 margin-bottom: 0;
363 div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
367 div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
371 div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
410 span.big { font-size: 2em; }
411 span.small { font-size: 0.6em; }
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
417 div.unbreakable { page-break-inside: avoid; }
421 * xhtml11 specific
423 * */
425 div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
429 div.tableblock > table {
430 border: 3px solid #527bbd;
432 thead, p.table.header {
433 font-weight: bold;
434 color: #527bbd;
436 p.table {
437 margin-top: 0;
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock > table[frame="void"] {
441 border-style: none;
443 div.tableblock > table[frame="hsides"] {
444 border-left-style: none;
445 border-right-style: none;
447 div.tableblock > table[frame="vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
454 * html5 specific
456 * */
458 table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
462 thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
466 p.tableblock {
467 margin-top: 0;
469 table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
480 border-color: #527bbd;
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
491 table.tableblock.frame-none {
492 border-style: hidden;
495 th.tableblock.halign-left, td.tableblock.halign-left {
496 text-align: left;
498 th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
501 th.tableblock.halign-right, td.tableblock.halign-right {
502 text-align: right;
505 th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: top;
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
517 * manpage specific
519 * */
521 body.manpage h1 {
522 padding-top: 0.5em;
523 padding-bottom: 0.5em;
524 border-top: 2px solid silver;
525 border-bottom: 2px solid silver;
527 body.manpage h2 {
528 border-style: none;
530 body.manpage div.sectionbody {
531 margin-left: 3em;
534 @media print {
535 body.manpage div#toc { display: none; }
539 </style>
540 <script type="text/javascript">
541 /*<![CDATA[*/
542 var asciidoc = { // Namespace.
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
548 /* Author: Mihai Bazon, September 2002
549 * http://students.infoiasi.ro/~mishoo
551 * Table Of Content generator
552 * Version: 0.4
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
558 /* modified by Troy D. Hanson, September 2006. License: GPL */
559 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
561 // toclevels = 1..4.
562 toc: function (toclevels) {
564 function getText(el) {
565 var text = "";
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
568 text += i.data;
569 else if (i.firstChild != null)
570 text += getText(i);
572 return text;
575 function TocEntry(el, text, toclevel) {
576 this.element = el;
577 this.text = text;
578 this.toclevel = toclevel;
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
586 // browsers).
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
594 iterate(i);
598 iterate(el);
599 return result;
602 var toc = document.getElementById("toc");
603 if (!toc) {
604 return;
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
609 var i;
610 for (i = 0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute("class")
614 && entry.getAttribute("class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
617 for (i = 0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById("content"), toclevels);
623 for (var i = 0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id == "")
626 entry.element.id = "_toc_" + i;
627 var a = document.createElement("a");
628 a.href = "#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement("div");
631 div.appendChild(a);
632 div.className = "toclevel" + entry.toclevel;
633 toc.appendChild(div);
635 if (entries.length == 0)
636 toc.parentNode.removeChild(toc);
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
650 var i;
651 var noteholder = document.getElementById("footnotes");
652 if (!noteholder) {
653 return;
655 var entriesToRemove = [];
656 for (i = 0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
659 entriesToRemove.push(entry);
661 for (i = 0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
665 // Rebuild footnote entries.
666 var cont = document.getElementById("content");
667 var spans = cont.getElementsByTagName("span");
668 var refs = {};
669 var n = 0;
670 for (i=0; i<spans.length; i++) {
671 if (spans[i].className == "footnote") {
672 n++;
673 var note = spans[i].getAttribute("data-note");
674 if (!note) {
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
678 spans[i].innerHTML =
679 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n + "</a>]";
681 spans[i].setAttribute("data-note", note);
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n + "'>" +
685 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
686 n + "</a>. " + note + "</div>";
687 var id =spans[i].getAttribute("id");
688 if (id != null) refs["#"+id] = n;
691 if (n == 0)
692 noteholder.parentNode.removeChild(noteholder);
693 else {
694 // Process footnoterefs.
695 for (i=0; i<spans.length; i++) {
696 if (spans[i].className == "footnoteref") {
697 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
698 href = href.match(/#.*/)[0]; // Because IE return full URL.
699 n = refs[href];
700 spans[i].innerHTML =
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n + "</a>]";
708 install: function(toclevels) {
709 var timerId;
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
731 asciidoc.install();
732 /*]]>*/
733 </script>
734 </head>
735 <body class="manpage">
736 <div id="header">
737 <h1>
738 git-maintenance(1) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>git-maintenance -
743 Run tasks to optimize Git repository data
744 </p>
745 </div>
746 </div>
747 <div id="content">
748 <div class="sect1">
749 <h2 id="_synopsis">SYNOPSIS</h2>
750 <div class="sectionbody">
751 <div class="verseblock">
752 <pre class="content"><em>git maintenance</em> run [&lt;options&gt;]
753 <em>git maintenance</em> start [--scheduler=&lt;scheduler&gt;]
754 <em>git maintenance</em> (stop|register|unregister) [&lt;options&gt;]</pre>
755 <div class="attribution">
756 </div></div>
757 </div>
758 </div>
759 <div class="sect1">
760 <h2 id="_description">DESCRIPTION</h2>
761 <div class="sectionbody">
762 <div class="paragraph"><p>Run tasks to optimize Git repository data, speeding up other Git commands
763 and reducing storage requirements for the repository.</p></div>
764 <div class="paragraph"><p>Git commands that add repository data, such as <code>git add</code> or <code>git fetch</code>,
765 are optimized for a responsive user experience. These commands do not take
766 time to optimize the Git data, since such optimizations scale with the full
767 size of the repository while these user commands each perform a relatively
768 small action.</p></div>
769 <div class="paragraph"><p>The <code>git maintenance</code> command provides flexibility for how to optimize the
770 Git repository.</p></div>
771 </div>
772 </div>
773 <div class="sect1">
774 <h2 id="_subcommands">SUBCOMMANDS</h2>
775 <div class="sectionbody">
776 <div class="dlist"><dl>
777 <dt class="hdlist1">
779 </dt>
780 <dd>
782 Run one or more maintenance tasks. If one or more <code>--task</code> options
783 are specified, then those tasks are run in that order. Otherwise,
784 the tasks are determined by which <code>maintenance.&lt;task&gt;.enabled</code>
785 config options are true. By default, only <code>maintenance.gc.enabled</code>
786 is true.
787 </p>
788 </dd>
789 <dt class="hdlist1">
790 start
791 </dt>
792 <dd>
794 Start running maintenance on the current repository. This performs
795 the same config updates as the <code>register</code> subcommand, then updates
796 the background scheduler to run <code>git maintenance run --scheduled</code>
797 on an hourly basis.
798 </p>
799 </dd>
800 <dt class="hdlist1">
801 stop
802 </dt>
803 <dd>
805 Halt the background maintenance schedule. The current repository
806 is not removed from the list of maintained repositories, in case
807 the background maintenance is restarted later.
808 </p>
809 </dd>
810 <dt class="hdlist1">
811 register
812 </dt>
813 <dd>
815 Initialize Git config values so any scheduled maintenance will start
816 running on this repository. This adds the repository to the
817 <code>maintenance.repo</code> config variable in the current user&#8217;s global config,
818 or the config specified by --config-file option, and enables some
819 recommended configuration values for <code>maintenance.&lt;task&gt;.schedule</code>. The
820 tasks that are enabled are safe for running in the background without
821 disrupting foreground processes.
822 </p>
823 <div class="paragraph"><p>The <code>register</code> subcommand will also set the <code>maintenance.strategy</code> config
824 value to <code>incremental</code>, if this value is not previously set. The
825 <code>incremental</code> strategy uses the following schedule for each maintenance
826 task:</p></div>
827 <div class="openblock">
828 <div class="content">
829 <div class="ulist"><ul>
830 <li>
832 <code>gc</code>: disabled.
833 </p>
834 </li>
835 <li>
837 <code>commit-graph</code>: hourly.
838 </p>
839 </li>
840 <li>
842 <code>prefetch</code>: hourly.
843 </p>
844 </li>
845 <li>
847 <code>loose-objects</code>: daily.
848 </p>
849 </li>
850 <li>
852 <code>incremental-repack</code>: daily.
853 </p>
854 </li>
855 </ul></div>
856 </div></div>
857 <div class="paragraph"><p><code>git maintenance register</code> will also disable foreground maintenance by
858 setting <code>maintenance.auto = false</code> in the current repository. This config
859 setting will remain after a <code>git maintenance unregister</code> command.</p></div>
860 </dd>
861 <dt class="hdlist1">
862 unregister
863 </dt>
864 <dd>
866 Remove the current repository from background maintenance. This
867 only removes the repository from the configured list. It does not
868 stop the background maintenance processes from running.
869 </p>
870 <div class="paragraph"><p>The <code>unregister</code> subcommand will report an error if the current repository
871 is not already registered. Use the <code>--force</code> option to return success even
872 when the current repository is not registered.</p></div>
873 </dd>
874 </dl></div>
875 </div>
876 </div>
877 <div class="sect1">
878 <h2 id="_tasks">TASKS</h2>
879 <div class="sectionbody">
880 <div class="dlist"><dl>
881 <dt class="hdlist1">
882 commit-graph
883 </dt>
884 <dd>
886 The <code>commit-graph</code> job updates the <code>commit-graph</code> files incrementally,
887 then verifies that the written data is correct. The incremental
888 write is safe to run alongside concurrent Git processes since it
889 will not expire <code>.graph</code> files that were in the previous
890 <code>commit-graph-chain</code> file. They will be deleted by a later run based
891 on the expiration delay.
892 </p>
893 </dd>
894 <dt class="hdlist1">
895 prefetch
896 </dt>
897 <dd>
899 The <code>prefetch</code> task updates the object directory with the latest
900 objects from all registered remotes. For each remote, a <code>git fetch</code>
901 command is run. The configured refspec is modified to place all
902 requested refs within <code>refs/prefetch/</code>. Also, tags are not updated.
903 </p>
904 <div class="paragraph"><p>This is done to avoid disrupting the remote-tracking branches. The end users
905 expect these refs to stay unmoved unless they initiate a fetch. However,
906 with the prefetch task, the objects necessary to complete a later real fetch
907 would already be obtained, making the real fetch faster. In the ideal case,
908 it will just become an update to a bunch of remote-tracking branches without
909 any object transfer.</p></div>
910 </dd>
911 <dt class="hdlist1">
913 </dt>
914 <dd>
916 Clean up unnecessary files and optimize the local repository. "GC"
917 stands for "garbage collection," but this task performs many
918 smaller tasks. This task can be expensive for large repositories,
919 as it repacks all Git objects into a single pack-file. It can also
920 be disruptive in some situations, as it deletes stale data. See
921 <a href="git-gc.html">git-gc(1)</a> for more details on garbage collection in Git.
922 </p>
923 </dd>
924 <dt class="hdlist1">
925 loose-objects
926 </dt>
927 <dd>
929 The <code>loose-objects</code> job cleans up loose objects and places them into
930 pack-files. In order to prevent race conditions with concurrent Git
931 commands, it follows a two-step process. First, it deletes any loose
932 objects that already exist in a pack-file; concurrent Git processes
933 will examine the pack-file for the object data instead of the loose
934 object. Second, it creates a new pack-file (starting with "loose-")
935 containing a batch of loose objects. The batch size is limited to 50
936 thousand objects to prevent the job from taking too long on a
937 repository with many loose objects. The <code>gc</code> task writes unreachable
938 objects as loose objects to be cleaned up by a later step only if
939 they are not re-added to a pack-file; for this reason it is not
940 advisable to enable both the <code>loose-objects</code> and <code>gc</code> tasks at the
941 same time.
942 </p>
943 </dd>
944 <dt class="hdlist1">
945 incremental-repack
946 </dt>
947 <dd>
949 The <code>incremental-repack</code> job repacks the object directory
950 using the <code>multi-pack-index</code> feature. In order to prevent race
951 conditions with concurrent Git commands, it follows a two-step
952 process. First, it calls <code>git multi-pack-index expire</code> to delete
953 pack-files unreferenced by the <code>multi-pack-index</code> file. Second, it
954 calls <code>git multi-pack-index repack</code> to select several small
955 pack-files and repack them into a bigger one, and then update the
956 <code>multi-pack-index</code> entries that refer to the small pack-files to
957 refer to the new pack-file. This prepares those small pack-files
958 for deletion upon the next run of <code>git multi-pack-index expire</code>.
959 The selection of the small pack-files is such that the expected
960 size of the big pack-file is at least the batch size; see the
961 <code>--batch-size</code> option for the <code>repack</code> subcommand in
962 <a href="git-multi-pack-index.html">git-multi-pack-index(1)</a>. The default batch-size is zero,
963 which is a special case that attempts to repack all pack-files
964 into a single pack-file.
965 </p>
966 </dd>
967 <dt class="hdlist1">
968 pack-refs
969 </dt>
970 <dd>
972 The <code>pack-refs</code> task collects the loose reference files and
973 collects them into a single file. This speeds up operations that
974 need to iterate across many references. See <a href="git-pack-refs.html">git-pack-refs(1)</a>
975 for more information.
976 </p>
977 </dd>
978 </dl></div>
979 </div>
980 </div>
981 <div class="sect1">
982 <h2 id="_options">OPTIONS</h2>
983 <div class="sectionbody">
984 <div class="dlist"><dl>
985 <dt class="hdlist1">
986 --auto
987 </dt>
988 <dd>
990 When combined with the <code>run</code> subcommand, run maintenance tasks
991 only if certain thresholds are met. For example, the <code>gc</code> task
992 runs when the number of loose objects exceeds the number stored
993 in the <code>gc.auto</code> config setting, or when the number of pack-files
994 exceeds the <code>gc.autoPackLimit</code> config setting. Not compatible with
995 the <code>--schedule</code> option.
996 </p>
997 </dd>
998 <dt class="hdlist1">
999 --schedule
1000 </dt>
1001 <dd>
1003 When combined with the <code>run</code> subcommand, run maintenance tasks
1004 only if certain time conditions are met, as specified by the
1005 <code>maintenance.&lt;task&gt;.schedule</code> config value for each <code>&lt;task&gt;</code>.
1006 This config value specifies a number of seconds since the last
1007 time that task ran, according to the <code>maintenance.&lt;task&gt;.lastRun</code>
1008 config value. The tasks that are tested are those provided by
1009 the <code>--task=&lt;task&gt;</code> option(s) or those with
1010 <code>maintenance.&lt;task&gt;.enabled</code> set to true.
1011 </p>
1012 </dd>
1013 <dt class="hdlist1">
1014 --quiet
1015 </dt>
1016 <dd>
1018 Do not report progress or other information over <code>stderr</code>.
1019 </p>
1020 </dd>
1021 <dt class="hdlist1">
1022 --task=&lt;task&gt;
1023 </dt>
1024 <dd>
1026 If this option is specified one or more times, then only run the
1027 specified tasks in the specified order. If no <code>--task=&lt;task&gt;</code>
1028 arguments are specified, then only the tasks with
1029 <code>maintenance.&lt;task&gt;.enabled</code> configured as <code>true</code> are considered.
1030 See the <em>TASKS</em> section for the list of accepted <code>&lt;task&gt;</code> values.
1031 </p>
1032 </dd>
1033 <dt class="hdlist1">
1034 --scheduler=auto|crontab|systemd-timer|launchctl|schtasks
1035 </dt>
1036 <dd>
1038 When combined with the <code>start</code> subcommand, specify the scheduler
1039 for running the hourly, daily and weekly executions of
1040 <code>git maintenance run</code>.
1041 Possible values for <code>&lt;scheduler&gt;</code> are <code>auto</code>, <code>crontab</code>
1042 (POSIX), <code>systemd-timer</code> (Linux), <code>launchctl</code> (macOS), and
1043 <code>schtasks</code> (Windows). When <code>auto</code> is specified, the
1044 appropriate platform-specific scheduler is used; on Linux,
1045 <code>systemd-timer</code> is used if available, otherwise
1046 <code>crontab</code>. Default is <code>auto</code>.
1047 </p>
1048 </dd>
1049 </dl></div>
1050 </div>
1051 </div>
1052 <div class="sect1">
1053 <h2 id="_troubleshooting">TROUBLESHOOTING</h2>
1054 <div class="sectionbody">
1055 <div class="paragraph"><p>The <code>git maintenance</code> command is designed to simplify the repository
1056 maintenance patterns while minimizing user wait time during Git commands.
1057 A variety of configuration options are available to allow customizing this
1058 process. The default maintenance options focus on operations that complete
1059 quickly, even on large repositories.</p></div>
1060 <div class="paragraph"><p>Users may find some cases where scheduled maintenance tasks do not run as
1061 frequently as intended. Each <code>git maintenance run</code> command takes a lock on
1062 the repository&#8217;s object database, and this prevents other concurrent
1063 <code>git maintenance run</code> commands from running on the same repository. Without
1064 this safeguard, competing processes could leave the repository in an
1065 unpredictable state.</p></div>
1066 <div class="paragraph"><p>The background maintenance schedule runs <code>git maintenance run</code> processes
1067 on an hourly basis. Each run executes the "hourly" tasks. At midnight,
1068 that process also executes the "daily" tasks. At midnight on the first day
1069 of the week, that process also executes the "weekly" tasks. A single
1070 process iterates over each registered repository, performing the scheduled
1071 tasks for that frequency. Depending on the number of registered
1072 repositories and their sizes, this process may take longer than an hour.
1073 In this case, multiple <code>git maintenance run</code> commands may run on the same
1074 repository at the same time, colliding on the object database lock. This
1075 results in one of the two tasks not running.</p></div>
1076 <div class="paragraph"><p>If you find that some maintenance windows are taking longer than one hour
1077 to complete, then consider reducing the complexity of your maintenance
1078 tasks. For example, the <code>gc</code> task is much slower than the
1079 <code>incremental-repack</code> task. However, this comes at a cost of a slightly
1080 larger object database. Consider moving more expensive tasks to be run
1081 less frequently.</p></div>
1082 <div class="paragraph"><p>Expert users may consider scheduling their own maintenance tasks using a
1083 different schedule than is available through <code>git maintenance start</code> and
1084 Git configuration options. These users should be aware of the object
1085 database lock and how concurrent <code>git maintenance run</code> commands behave.
1086 Further, the <code>git gc</code> command should not be combined with
1087 <code>git maintenance run</code> commands. <code>git gc</code> modifies the object database
1088 but does not take the lock in the same way as <code>git maintenance run</code>. If
1089 possible, use <code>git maintenance run --task=gc</code> instead of <code>git gc</code>.</p></div>
1090 <div class="paragraph"><p>The following sections describe the mechanisms put in place to run
1091 background maintenance by <code>git maintenance start</code> and how to customize
1092 them.</p></div>
1093 </div>
1094 </div>
1095 <div class="sect1">
1096 <h2 id="_background_maintenance_on_posix_systems">BACKGROUND MAINTENANCE ON POSIX SYSTEMS</h2>
1097 <div class="sectionbody">
1098 <div class="paragraph"><p>The standard mechanism for scheduling background tasks on POSIX systems
1099 is cron(8). This tool executes commands based on a given schedule. The
1100 current list of user-scheduled tasks can be found by running <code>crontab -l</code>.
1101 The schedule written by <code>git maintenance start</code> is similar to this:</p></div>
1102 <div class="listingblock">
1103 <div class="content">
1104 <pre><code># BEGIN GIT MAINTENANCE SCHEDULE
1105 # The following schedule was created by Git
1106 # Any edits made in this region might be
1107 # replaced in the future by a Git command.
1109 0 1-23 * * * "/&lt;path&gt;/git" --exec-path="/&lt;path&gt;" for-each-repo --config=maintenance.repo maintenance run --schedule=hourly
1110 0 0 * * 1-6 "/&lt;path&gt;/git" --exec-path="/&lt;path&gt;" for-each-repo --config=maintenance.repo maintenance run --schedule=daily
1111 0 0 * * 0 "/&lt;path&gt;/git" --exec-path="/&lt;path&gt;" for-each-repo --config=maintenance.repo maintenance run --schedule=weekly
1113 # END GIT MAINTENANCE SCHEDULE</code></pre>
1114 </div></div>
1115 <div class="paragraph"><p>The comments are used as a region to mark the schedule as written by Git.
1116 Any modifications within this region will be completely deleted by
1117 <code>git maintenance stop</code> or overwritten by <code>git maintenance start</code>.</p></div>
1118 <div class="paragraph"><p>The <code>crontab</code> entry specifies the full path of the <code>git</code> executable to
1119 ensure that the executed <code>git</code> command is the same one with which
1120 <code>git maintenance start</code> was issued independent of <code>PATH</code>. If the same user
1121 runs <code>git maintenance start</code> with multiple Git executables, then only the
1122 latest executable is used.</p></div>
1123 <div class="paragraph"><p>These commands use <code>git for-each-repo --config=maintenance.repo</code> to run
1124 <code>git maintenance run --schedule=&lt;frequency&gt;</code> on each repository listed in
1125 the multi-valued <code>maintenance.repo</code> config option. These are typically
1126 loaded from the user-specific global config. The <code>git maintenance</code> process
1127 then determines which maintenance tasks are configured to run on each
1128 repository with each <code>&lt;frequency&gt;</code> using the <code>maintenance.&lt;task&gt;.schedule</code>
1129 config options. These values are loaded from the global or repository
1130 config values.</p></div>
1131 <div class="paragraph"><p>If the config values are insufficient to achieve your desired background
1132 maintenance schedule, then you can create your own schedule. If you run
1133 <code>crontab -e</code>, then an editor will load with your user-specific <code>cron</code>
1134 schedule. In that editor, you can add your own schedule lines. You could
1135 start by adapting the default schedule listed earlier, or you could read
1136 the crontab(5) documentation for advanced scheduling techniques. Please
1137 do use the full path and <code>--exec-path</code> techniques from the default
1138 schedule to ensure you are executing the correct binaries in your
1139 schedule.</p></div>
1140 </div>
1141 </div>
1142 <div class="sect1">
1143 <h2 id="_background_maintenance_on_linux_systemd_systems">BACKGROUND MAINTENANCE ON LINUX SYSTEMD SYSTEMS</h2>
1144 <div class="sectionbody">
1145 <div class="paragraph"><p>While Linux supports <code>cron</code>, depending on the distribution, <code>cron</code> may
1146 be an optional package not necessarily installed. On modern Linux
1147 distributions, systemd timers are superseding it.</p></div>
1148 <div class="paragraph"><p>If user systemd timers are available, they will be used as a replacement
1149 of <code>cron</code>.</p></div>
1150 <div class="paragraph"><p>In this case, <code>git maintenance start</code> will create user systemd timer units
1151 and start the timers. The current list of user-scheduled tasks can be found
1152 by running <code>systemctl --user list-timers</code>. The timers written by <code>git
1153 maintenance start</code> are similar to this:</p></div>
1154 <div class="listingblock">
1155 <div class="content">
1156 <pre><code>$ systemctl --user list-timers
1157 NEXT LEFT LAST PASSED UNIT ACTIVATES
1158 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
1159 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
1160 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</code></pre>
1161 </div></div>
1162 <div class="paragraph"><p>One timer is registered for each <code>--schedule=&lt;frequency&gt;</code> option.</p></div>
1163 <div class="paragraph"><p>The definition of the systemd units can be inspected in the following files:</p></div>
1164 <div class="listingblock">
1165 <div class="content">
1166 <pre><code>~/.config/systemd/user/git-maintenance@.timer
1167 ~/.config/systemd/user/git-maintenance@.service
1168 ~/.config/systemd/user/timers.target.wants/git-maintenance@hourly.timer
1169 ~/.config/systemd/user/timers.target.wants/git-maintenance@daily.timer
1170 ~/.config/systemd/user/timers.target.wants/git-maintenance@weekly.timer</code></pre>
1171 </div></div>
1172 <div class="paragraph"><p><code>git maintenance start</code> will overwrite these files and start the timer
1173 again with <code>systemctl --user</code>, so any customization should be done by
1174 creating a drop-in file, i.e. a <code>.conf</code> suffixed file in the
1175 <code>~/.config/systemd/user/git-maintenance@.service.d</code> directory.</p></div>
1176 <div class="paragraph"><p><code>git maintenance stop</code> will stop the user systemd timers and delete
1177 the above mentioned files.</p></div>
1178 <div class="paragraph"><p>For more details, see <code>systemd.timer(5)</code>.</p></div>
1179 </div>
1180 </div>
1181 <div class="sect1">
1182 <h2 id="_background_maintenance_on_macos_systems">BACKGROUND MAINTENANCE ON MACOS SYSTEMS</h2>
1183 <div class="sectionbody">
1184 <div class="paragraph"><p>While macOS technically supports <code>cron</code>, using <code>crontab -e</code> requires
1185 elevated privileges and the executed process does not have a full user
1186 context. Without a full user context, Git and its credential helpers
1187 cannot access stored credentials, so some maintenance tasks are not
1188 functional.</p></div>
1189 <div class="paragraph"><p>Instead, <code>git maintenance start</code> interacts with the <code>launchctl</code> tool,
1190 which is the recommended way to schedule timed jobs in macOS. Scheduling
1191 maintenance through <code>git maintenance (start|stop)</code> requires some
1192 <code>launchctl</code> features available only in macOS 10.11 or later.</p></div>
1193 <div class="paragraph"><p>Your user-specific scheduled tasks are stored as XML-formatted <code>.plist</code>
1194 files in <code>~/Library/LaunchAgents/</code>. You can see the currently-registered
1195 tasks using the following command:</p></div>
1196 <div class="listingblock">
1197 <div class="content">
1198 <pre><code>$ ls ~/Library/LaunchAgents/org.git-scm.git*
1199 org.git-scm.git.daily.plist
1200 org.git-scm.git.hourly.plist
1201 org.git-scm.git.weekly.plist</code></pre>
1202 </div></div>
1203 <div class="paragraph"><p>One task is registered for each <code>--schedule=&lt;frequency&gt;</code> option. To
1204 inspect how the XML format describes each schedule, open one of these
1205 <code>.plist</code> files in an editor and inspect the <code>&lt;array&gt;</code> element following
1206 the <code>&lt;key&gt;StartCalendarInterval&lt;/key&gt;</code> element.</p></div>
1207 <div class="paragraph"><p><code>git maintenance start</code> will overwrite these files and register the
1208 tasks again with <code>launchctl</code>, so any customizations should be done by
1209 creating your own <code>.plist</code> files with distinct names. Similarly, the
1210 <code>git maintenance stop</code> command will unregister the tasks with <code>launchctl</code>
1211 and delete the <code>.plist</code> files.</p></div>
1212 <div class="paragraph"><p>To create more advanced customizations to your background tasks, see
1213 launchctl.plist(5) for more information.</p></div>
1214 </div>
1215 </div>
1216 <div class="sect1">
1217 <h2 id="_background_maintenance_on_windows_systems">BACKGROUND MAINTENANCE ON WINDOWS SYSTEMS</h2>
1218 <div class="sectionbody">
1219 <div class="paragraph"><p>Windows does not support <code>cron</code> and instead has its own system for
1220 scheduling background tasks. The <code>git maintenance start</code> command uses
1221 the <code>schtasks</code> command to submit tasks to this system. You can inspect
1222 all background tasks using the Task Scheduler application. The tasks
1223 added by Git have names of the form <code>Git Maintenance (&lt;frequency&gt;)</code>.
1224 The Task Scheduler GUI has ways to inspect these tasks, but you can also
1225 export the tasks to XML files and view the details there.</p></div>
1226 <div class="paragraph"><p>Note that since Git is a console application, these background tasks
1227 create a console window visible to the current user. This can be changed
1228 manually by selecting the "Run whether user is logged in or not" option
1229 in Task Scheduler. This change requires a password input, which is why
1230 <code>git maintenance start</code> does not select it by default.</p></div>
1231 <div class="paragraph"><p>If you want to customize the background tasks, please rename the tasks
1232 so future calls to <code>git maintenance (start|stop)</code> do not overwrite your
1233 custom tasks.</p></div>
1234 </div>
1235 </div>
1236 <div class="sect1">
1237 <h2 id="_configuration">CONFIGURATION</h2>
1238 <div class="sectionbody">
1239 <div class="paragraph"><p>Everything below this line in this section is selectively included
1240 from the <a href="git-config.html">git-config(1)</a> documentation. The content is the same
1241 as what&#8217;s found there:</p></div>
1242 <div class="dlist"><dl>
1243 <dt class="hdlist1">
1244 maintenance.auto
1245 </dt>
1246 <dd>
1248 This boolean config option controls whether some commands run
1249 <code>git maintenance run --auto</code> after doing their normal work. Defaults
1250 to true.
1251 </p>
1252 </dd>
1253 <dt class="hdlist1">
1254 maintenance.strategy
1255 </dt>
1256 <dd>
1258 This string config option provides a way to specify one of a few
1259 recommended schedules for background maintenance. This only affects
1260 which tasks are run during <code>git maintenance run --schedule=X</code>
1261 commands, provided no <code>--task=&lt;task&gt;</code> arguments are provided.
1262 Further, if a <code>maintenance.&lt;task&gt;.schedule</code> config value is set,
1263 then that value is used instead of the one provided by
1264 <code>maintenance.strategy</code>. The possible strategy strings are:
1265 </p>
1266 <div class="ulist"><ul>
1267 <li>
1269 <code>none</code>: This default setting implies no tasks are run at any schedule.
1270 </p>
1271 </li>
1272 <li>
1274 <code>incremental</code>: This setting optimizes for performing small maintenance
1275 activities that do not delete any data. This does not schedule the <code>gc</code>
1276 task, but runs the <code>prefetch</code> and <code>commit-graph</code> tasks hourly, the
1277 <code>loose-objects</code> and <code>incremental-repack</code> tasks daily, and the <code>pack-refs</code>
1278 task weekly.
1279 </p>
1280 </li>
1281 </ul></div>
1282 </dd>
1283 <dt class="hdlist1">
1284 maintenance.&lt;task&gt;.enabled
1285 </dt>
1286 <dd>
1288 This boolean config option controls whether the maintenance task
1289 with name <code>&lt;task&gt;</code> is run when no <code>--task</code> option is specified to
1290 <code>git maintenance run</code>. These config values are ignored if a
1291 <code>--task</code> option exists. By default, only <code>maintenance.gc.enabled</code>
1292 is true.
1293 </p>
1294 </dd>
1295 <dt class="hdlist1">
1296 maintenance.&lt;task&gt;.schedule
1297 </dt>
1298 <dd>
1300 This config option controls whether or not the given <code>&lt;task&gt;</code> runs
1301 during a <code>git maintenance run --schedule=&lt;frequency&gt;</code> command. The
1302 value must be one of "hourly", "daily", or "weekly".
1303 </p>
1304 </dd>
1305 <dt class="hdlist1">
1306 maintenance.commit-graph.auto
1307 </dt>
1308 <dd>
1310 This integer config option controls how often the <code>commit-graph</code> task
1311 should be run as part of <code>git maintenance run --auto</code>. If zero, then
1312 the <code>commit-graph</code> task will not run with the <code>--auto</code> option. A
1313 negative value will force the task to run every time. Otherwise, a
1314 positive value implies the command should run when the number of
1315 reachable commits that are not in the commit-graph file is at least
1316 the value of <code>maintenance.commit-graph.auto</code>. The default value is
1317 100.
1318 </p>
1319 </dd>
1320 <dt class="hdlist1">
1321 maintenance.loose-objects.auto
1322 </dt>
1323 <dd>
1325 This integer config option controls how often the <code>loose-objects</code> task
1326 should be run as part of <code>git maintenance run --auto</code>. If zero, then
1327 the <code>loose-objects</code> task will not run with the <code>--auto</code> option. A
1328 negative value will force the task to run every time. Otherwise, a
1329 positive value implies the command should run when the number of
1330 loose objects is at least the value of <code>maintenance.loose-objects.auto</code>.
1331 The default value is 100.
1332 </p>
1333 </dd>
1334 <dt class="hdlist1">
1335 maintenance.incremental-repack.auto
1336 </dt>
1337 <dd>
1339 This integer config option controls how often the <code>incremental-repack</code>
1340 task should be run as part of <code>git maintenance run --auto</code>. If zero,
1341 then the <code>incremental-repack</code> task will not run with the <code>--auto</code>
1342 option. A negative value will force the task to run every time.
1343 Otherwise, a positive value implies the command should run when the
1344 number of pack-files not in the multi-pack-index is at least the value
1345 of <code>maintenance.incremental-repack.auto</code>. The default value is 10.
1346 </p>
1347 </dd>
1348 </dl></div>
1349 </div>
1350 </div>
1351 <div class="sect1">
1352 <h2 id="_git">GIT</h2>
1353 <div class="sectionbody">
1354 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1355 </div>
1356 </div>
1357 </div>
1358 <div id="footnotes"><hr /></div>
1359 <div id="footer">
1360 <div id="footer-text">
1361 Last updated
1362 2023-10-23 14:43:46 PDT
1363 </div>
1364 </div>
1365 </body>
1366 </html>