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