blob: fa1510480a1d55236f2c467a0d4e901bbc60dc84 [file] [log] [blame]
Junio C Hamano52299462006-12-28 00:59:381git-gc(1)
2=========
3
4NAME
5----
6git-gc - Cleanup unnecessary files and optimize the local repository
7
8
9SYNOPSIS
10--------
Junio C Hamano15567bc2011-07-23 00:51:5911[verse]
Junio C Hamano535ed7a2013-09-04 20:35:5712'git gc' [--aggressive] [--auto] [--quiet] [--prune=<date> | --no-prune] [--force]
Junio C Hamano52299462006-12-28 00:59:3813
14DESCRIPTION
15-----------
16Runs a number of housekeeping tasks within the current repository,
17such as compressing file revisions (to reduce disk space and increase
18performance) and removing unreachable objects which may have been
Junio C Hamano1aa40d22010-01-21 17:46:4319created from prior invocations of 'git add'.
Junio C Hamano52299462006-12-28 00:59:3820
21Users are encouraged to run this task on a regular basis within
22each repository to maintain good disk space utilization and good
Junio C Hamanod04b60c2008-03-20 08:46:0423operating performance.
24
Junio C Hamano1aa40d22010-01-21 17:46:4325Some git commands may automatically run 'git gc'; see the `--auto` flag
Junio C Hamanod04b60c2008-03-20 08:46:0426below for details. If you know what you're doing and all you want is to
27disable this behavior permanently without further considerations, just do:
28
29----------------------
30$ git config --global gc.auto 0
31----------------------
Junio C Hamano52299462006-12-28 00:59:3832
Junio C Hamanof65d9282007-01-22 09:00:1333OPTIONS
34-------
35
Junio C Hamanof2ce2972007-05-20 19:12:0936--aggressive::
Junio C Hamano1aa40d22010-01-21 17:46:4337Usually 'git gc' runs very quickly while providing good disk
Junio C Hamano679d22d2007-06-02 21:13:4438space utilization and performance. This option will cause
Junio C Hamano1aa40d22010-01-21 17:46:4339'git gc' to more aggressively optimize the repository at the expense
Junio C Hamanof2ce2972007-05-20 19:12:0940of taking much more time. The effects of this optimization are
Junio C Hamano679d22d2007-06-02 21:13:4441persistent, so this option only needs to be used occasionally; every
Junio C Hamanof2ce2972007-05-20 19:12:0942few hundred changesets or so.
Junio C Hamanof65d9282007-01-22 09:00:1343
Junio C Hamano1b50ce92007-10-03 12:05:5344--auto::
Junio C Hamano1aa40d22010-01-21 17:46:4345With this option, 'git gc' checks whether any housekeeping is
Junio C Hamano764a6672007-10-23 01:23:3146required; if not, it exits without performing any work.
47Some git commands run `git gc --auto` after performing
48operations that could create many loose objects.
49+
50Housekeeping is required if there are too many loose objects or
51too many packs in the repository. If the number of loose objects
52exceeds the value of the `gc.auto` configuration variable, then
53all loose objects are combined into a single pack using
Junio C Hamano1aa40d22010-01-21 17:46:4354`git repack -d -l`. Setting the value of `gc.auto` to 0
Junio C Hamano764a6672007-10-23 01:23:3155disables automatic packing of loose objects.
56+
Junio C Hamano322c6242015-03-23 21:32:4657If the number of packs exceeds the value of `gc.autoPackLimit`,
Junio C Hamano764a6672007-10-23 01:23:3158then existing packs (except those marked with a `.keep` file)
59are consolidated into a single pack by using the `-A` option of
Junio C Hamano322c6242015-03-23 21:32:4660'git repack'. Setting `gc.autoPackLimit` to 0 disables
Junio C Hamano764a6672007-10-23 01:23:3161automatic consolidation of packs.
Junio C Hamano1b50ce92007-10-03 12:05:5362
Junio C Hamano8bc410e2009-02-15 10:38:1963--prune=<date>::
64Prune loose objects older than date (default is 2 weeks ago,
Junio C Hamanoc7102962013-05-29 23:57:1765overridable by the config variable `gc.pruneExpire`).
Junio C Hamano2990bb52015-10-16 22:07:5866--prune=all prunes loose objects regardless of their age (do
67not use --prune=all unless you know exactly what you are doing.
68Unless the repository is quiescent, you will lose newly created
69objects that haven't been anchored with the refs and end up
70corrupting your repository). --prune is on by default.
Junio C Hamano8bc410e2009-02-15 10:38:1971
72--no-prune::
73Do not prune any loose objects.
74
Junio C Hamano69a98582008-03-01 18:42:1875--quiet::
76Suppress all progress reports.
77
Junio C Hamano535ed7a2013-09-04 20:35:5778--force::
79Force `git gc` to run even if there may be another `git gc`
80instance running on this repository.
81
Junio C Hamano52299462006-12-28 00:59:3882Configuration
83-------------
84
85The optional configuration variable 'gc.reflogExpire' can be
86set to indicate how long historical entries within each branch's
87reflog should remain available in this repository. The setting is
88expressed as a length of time, for example '90 days' or '3 months'.
89It defaults to '90 days'.
90
91The optional configuration variable 'gc.reflogExpireUnreachable'
92can be set to indicate how long historical reflog entries which
93are not part of the current branch should remain available in
94this repository. These types of entries are generally created as
Junio C Hamanob76a6862012-05-02 22:02:4695a result of using `git commit --amend` or `git rebase` and are the
Junio C Hamanof9771f62007-01-17 17:42:3096commits prior to the amend or rebase occurring. Since these changes
Junio C Hamano52299462006-12-28 00:59:3897are not part of the current project most users will want to expire
98them sooner. This option defaults to '30 days'.
99
Junio C Hamanocc7636a2010-05-21 14:57:53100The above two configuration variables can be given to a pattern. For
Junio C Hamano97bcb482010-11-25 03:16:07101example, this sets non-default expiry values only to remote-tracking
Junio C Hamanocc7636a2010-05-21 14:57:53102branches:
103
104------------
105[gc "refs/remotes/*"]
106reflogExpire = never
Junio C Hamano322c6242015-03-23 21:32:46107reflogExpireUnreachable = 3 days
Junio C Hamanocc7636a2010-05-21 14:57:53108------------
109
Junio C Hamano322c6242015-03-23 21:32:46110The optional configuration variable 'gc.rerereResolved' indicates
Junio C Hamano52299462006-12-28 00:59:38111how long records of conflicted merge you resolved earlier are
112kept. This defaults to 60 days.
113
Junio C Hamano322c6242015-03-23 21:32:46114The optional configuration variable 'gc.rerereUnresolved' indicates
Junio C Hamano52299462006-12-28 00:59:38115how long records of conflicted merge you have not resolved are
116kept. This defaults to 15 days.
117
Junio C Hamano322c6242015-03-23 21:32:46118The optional configuration variable 'gc.packRefs' determines if
Junio C Hamanocdd1c332010-12-20 10:08:00119'git gc' runs 'git pack-refs'. This can be set to "notbare" to enable
Junio C Hamanoe77b0152008-01-12 06:44:17120it within all non-bare repos or it can be set to a boolean value.
121This defaults to true.
Junio C Hamano52299462006-12-28 00:59:38122
Junio C Hamanof2ce2972007-05-20 19:12:09123The optional configuration variable 'gc.aggressiveWindow' controls how
124much time is spent optimizing the delta compression of the objects in
125the repository when the --aggressive option is specified. The larger
126the value, the more time is spent optimizing the delta compression. See
Junio C Hamano35738e82008-01-07 07:55:46127the documentation for the --window' option in linkgit:git-repack[1] for
Junio C Hamanoae4a8f32009-10-04 09:54:54128more details. This defaults to 250.
Junio C Hamanof2ce2972007-05-20 19:12:09129
Junio C Hamano624dd4c2014-04-03 21:56:30130Similarly, the optional configuration variable 'gc.aggressiveDepth'
131controls --depth option in linkgit:git-repack[1]. This defaults to 250.
132
Junio C Hamano09a926d2008-03-13 07:55:29133The optional configuration variable 'gc.pruneExpire' controls how old
134the unreferenced loose objects have to be before they are pruned. The
135default is "2 weeks ago".
136
Junio C Hamano2f102bb2008-04-26 02:23:37137
138Notes
139-----
140
Junio C Hamano1aa40d22010-01-21 17:46:43141'git gc' tries very hard to be safe about the garbage it collects. In
Junio C Hamano2f102bb2008-04-26 02:23:37142particular, it will keep not only objects referenced by your current set
Junio C Hamano97bcb482010-11-25 03:16:07143of branches and tags, but also objects referenced by the index,
144remote-tracking branches, refs saved by 'git filter-branch' in
Junio C Hamano4232bc42009-10-20 07:49:31145refs/original/, or reflogs (which may reference commits in branches
Junio C Hamano2f102bb2008-04-26 02:23:37146that were later amended or rewound).
147
148If you are expecting some objects to be collected and they aren't, check
149all of those locations and decide whether it makes sense in your case to
150remove those references.
151
Junio C Hamano3e3aa812010-07-05 23:25:23152HOOKS
153-----
154
155The 'git gc --auto' command will run the 'pre-auto-gc' hook. See
156linkgit:githooks[5] for more information.
157
158
Junio C Hamano9049d912008-05-29 02:09:50159SEE ALSO
Junio C Hamano52299462006-12-28 00:59:38160--------
Junio C Hamano35738e82008-01-07 07:55:46161linkgit:git-prune[1]
162linkgit:git-reflog[1]
163linkgit:git-repack[1]
164linkgit:git-rerere[1]
Junio C Hamano52299462006-12-28 00:59:38165
Junio C Hamano52299462006-12-28 00:59:38166GIT
167---
Junio C Hamanof7c042d2008-06-06 22:50:53168Part of the linkgit:git[1] suite