updated git doc
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-gc.xml
blob6972a6796c5f2f61760551ebc6bb7ef28731e933
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <article lang="en" id="git-gc(1)">\r
5 <articleinfo>\r
6     <title>git-gc(1)</title>\r
7 <indexterm>\r
8 <primary>git-gc(1)</primary>\r
9 </indexterm>\r
10 </articleinfo>\r
11 <simplesect id="_name">\r
12 <title>NAME</title>\r
13 <simpara>git-gc - Cleanup unnecessary files and optimize the local repository</simpara>\r
14 </simplesect>\r
15 <simplesect id="_synopsis">\r
16 <title>SYNOPSIS</title>\r
17 <blockquote>\r
18 <literallayout><emphasis>git gc</emphasis> [--aggressive] [--auto] [--quiet] [--prune=&lt;date&gt; | --no-prune]</literallayout>\r
19 </blockquote>\r
20 </simplesect>\r
21 <simplesect id="_description">\r
22 <title>DESCRIPTION</title>\r
23 <simpara>Runs a number of housekeeping tasks within the current repository,\r
24 such as compressing file revisions (to reduce disk space and increase\r
25 performance) and removing unreachable objects which may have been\r
26 created from prior invocations of <emphasis>git add</emphasis>.</simpara>\r
27 <simpara>Users are encouraged to run this task on a regular basis within\r
28 each repository to maintain good disk space utilization and good\r
29 operating performance.</simpara>\r
30 <simpara>Some git commands may automatically run <emphasis>git gc</emphasis>; see the <emphasis>--auto</emphasis> flag\r
31 below for details. If you know what you're doing and all you want is to\r
32 disable this behavior permanently without further considerations, just do:</simpara>\r
33 <screen>$ git config --global gc.auto 0</screen>\r
34 </simplesect>\r
35 <simplesect id="_options">\r
36 <title>OPTIONS</title>\r
37 <variablelist>\r
38 <varlistentry>\r
39 <term>\r
40 --aggressive\r
41 </term>\r
42 <listitem>\r
43 <simpara>\r
44         Usually <emphasis>git gc</emphasis> runs very quickly while providing good disk\r
45         space utilization and performance.  This option will cause\r
46         <emphasis>git gc</emphasis> to more aggressively optimize the repository at the expense\r
47         of taking much more time.  The effects of this optimization are\r
48         persistent, so this option only needs to be used occasionally; every\r
49         few hundred changesets or so.\r
50 </simpara>\r
51 </listitem>\r
52 </varlistentry>\r
53 <varlistentry>\r
54 <term>\r
55 --auto\r
56 </term>\r
57 <listitem>\r
58 <simpara>\r
59         With this option, <emphasis>git gc</emphasis> checks whether any housekeeping is\r
60         required; if not, it exits without performing any work.\r
61         Some git commands run <emphasis>git gc --auto</emphasis> after performing\r
62         operations that could create many loose objects.\r
63 </simpara>\r
64 <simpara>Housekeeping is required if there are too many loose objects or\r
65 too many packs in the repository. If the number of loose objects\r
66 exceeds the value of the <emphasis>gc.auto</emphasis> configuration variable, then\r
67 all loose objects are combined into a single pack using\r
68 <emphasis>git repack -d -l</emphasis>.  Setting the value of <emphasis>gc.auto</emphasis> to 0\r
69 disables automatic packing of loose objects.</simpara>\r
70 <simpara>If the number of packs exceeds the value of <emphasis>gc.autopacklimit</emphasis>,\r
71 then existing packs (except those marked with a <emphasis>.keep</emphasis> file)\r
72 are consolidated into a single pack by using the <emphasis>-A</emphasis> option of\r
73 <emphasis>git repack</emphasis>. Setting <emphasis>gc.autopacklimit</emphasis> to 0 disables\r
74 automatic consolidation of packs.</simpara>\r
75 </listitem>\r
76 </varlistentry>\r
77 <varlistentry>\r
78 <term>\r
79 --prune=&lt;date&gt;\r
80 </term>\r
81 <listitem>\r
82 <simpara>\r
83         Prune loose objects older than date (default is 2 weeks ago,\r
84         overridable by the config variable <emphasis>gc.pruneExpire</emphasis>).  This\r
85         option is on by default.\r
86 </simpara>\r
87 </listitem>\r
88 </varlistentry>\r
89 <varlistentry>\r
90 <term>\r
91 --no-prune\r
92 </term>\r
93 <listitem>\r
94 <simpara>\r
95         Do not prune any loose objects.\r
96 </simpara>\r
97 </listitem>\r
98 </varlistentry>\r
99 <varlistentry>\r
100 <term>\r
101 --quiet\r
102 </term>\r
103 <listitem>\r
104 <simpara>\r
105         Suppress all progress reports.\r
106 </simpara>\r
107 </listitem>\r
108 </varlistentry>\r
109 </variablelist>\r
110 </simplesect>\r
111 <simplesect id="_configuration">\r
112 <title>Configuration</title>\r
113 <simpara>The optional configuration variable <emphasis>gc.reflogExpire</emphasis> can be\r
114 set to indicate how long historical entries within each branch's\r
115 reflog should remain available in this repository.  The setting is\r
116 expressed as a length of time, for example <emphasis>90 days</emphasis> or <emphasis>3 months</emphasis>.\r
117 It defaults to <emphasis>90 days</emphasis>.</simpara>\r
118 <simpara>The optional configuration variable <emphasis>gc.reflogExpireUnreachable</emphasis>\r
119 can be set to indicate how long historical reflog entries which\r
120 are not part of the current branch should remain available in\r
121 this repository.  These types of entries are generally created as\r
122 a result of using <emphasis>git commit --amend</emphasis> or <emphasis>git rebase</emphasis> and are the\r
123 commits prior to the amend or rebase occurring.  Since these changes\r
124 are not part of the current project most users will want to expire\r
125 them sooner.  This option defaults to <emphasis>30 days</emphasis>.</simpara>\r
126 <simpara>The above two configuration variables can be given to a pattern.  For\r
127 example, this sets non-default expiry values only to remote-tracking\r
128 branches:</simpara>\r
129 <screen>[gc "refs/remotes/*"]\r
130         reflogExpire = never\r
131         reflogexpireUnreachable = 3 days</screen>\r
132 <simpara>The optional configuration variable <emphasis>gc.rerereresolved</emphasis> indicates\r
133 how long records of conflicted merge you resolved earlier are\r
134 kept.  This defaults to 60 days.</simpara>\r
135 <simpara>The optional configuration variable <emphasis>gc.rerereunresolved</emphasis> indicates\r
136 how long records of conflicted merge you have not resolved are\r
137 kept.  This defaults to 15 days.</simpara>\r
138 <simpara>The optional configuration variable <emphasis>gc.packrefs</emphasis> determines if\r
139 <emphasis>git gc</emphasis> runs <emphasis>git pack-refs</emphasis>. This can be set to "notbare" to enable\r
140 it within all non-bare repos or it can be set to a boolean value.\r
141 This defaults to true.</simpara>\r
142 <simpara>The optional configuration variable <emphasis>gc.aggressiveWindow</emphasis> controls how\r
143 much time is spent optimizing the delta compression of the objects in\r
144 the repository when the --aggressive option is specified.  The larger\r
145 the value, the more time is spent optimizing the delta compression.  See\r
146 the documentation for the --window' option in <xref linkend="git-repack(1)" /> for\r
147 more details.  This defaults to 250.</simpara>\r
148 <simpara>The optional configuration variable <emphasis>gc.pruneExpire</emphasis> controls how old\r
149 the unreferenced loose objects have to be before they are pruned.  The\r
150 default is "2 weeks ago".</simpara>\r
151 </simplesect>\r
152 <simplesect id="_notes">\r
153 <title>Notes</title>\r
154 <simpara><emphasis>git gc</emphasis> tries very hard to be safe about the garbage it collects. In\r
155 particular, it will keep not only objects referenced by your current set\r
156 of branches and tags, but also objects referenced by the index,\r
157 remote-tracking branches, refs saved by <emphasis>git filter-branch</emphasis> in\r
158 refs/original/, or reflogs (which may reference commits in branches\r
159 that were later amended or rewound).</simpara>\r
160 <simpara>If you are expecting some objects to be collected and they aren't, check\r
161 all of those locations and decide whether it makes sense in your case to\r
162 remove those references.</simpara>\r
163 </simplesect>\r
164 <simplesect id="_hooks">\r
165 <title>HOOKS</title>\r
166 <simpara>The <emphasis>git gc --auto</emphasis> command will run the <emphasis>pre-auto-gc</emphasis> hook.  See\r
167 <xref linkend="githooks(5)" /> for more information.</simpara>\r
168 </simplesect>\r
169 <simplesect id="_see_also">\r
170 <title>SEE ALSO</title>\r
171 <simpara><xref linkend="git-prune(1)" />\r
172 <xref linkend="git-reflog(1)" />\r
173 <xref linkend="git-repack(1)" />\r
174 <xref linkend="git-rerere(1)" /></simpara>\r
175 </simplesect>\r
176 <simplesect id="_git">\r
177 <title>GIT</title>\r
178 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
179 </simplesect>\r
180 </article>\r