blob: 7086eea74a38b036130f61db362bae209a065e47 [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 Hamanofce7c7e2008-07-02 03:06:3811'git gc' [--aggressive] [--auto] [--quiet]
Junio C Hamano52299462006-12-28 00:59:3812
13DESCRIPTION
14-----------
15Runs a number of housekeeping tasks within the current repository,
16such as compressing file revisions (to reduce disk space and increase
17performance) and removing unreachable objects which may have been
Junio C Hamanoba4b9282008-07-06 05:20:3118created from prior invocations of 'git-add'.
Junio C Hamano52299462006-12-28 00:59:3819
20Users are encouraged to run this task on a regular basis within
21each repository to maintain good disk space utilization and good
Junio C Hamanod04b60c2008-03-20 08:46:0422operating performance.
23
Junio C Hamanoba4b9282008-07-06 05:20:3124Some git commands may automatically run 'git-gc'; see the `--auto` flag
Junio C Hamanod04b60c2008-03-20 08:46:0425below for details. If you know what you're doing and all you want is to
26disable this behavior permanently without further considerations, just do:
27
28----------------------
29$ git config --global gc.auto 0
30----------------------
Junio C Hamano52299462006-12-28 00:59:3831
Junio C Hamanof65d9282007-01-22 09:00:1332OPTIONS
33-------
34
Junio C Hamanof2ce2972007-05-20 19:12:0935--aggressive::
Junio C Hamanoba4b9282008-07-06 05:20:3136Usually 'git-gc' runs very quickly while providing good disk
Junio C Hamano679d22d2007-06-02 21:13:4437space utilization and performance. This option will cause
Junio C Hamanoba4b9282008-07-06 05:20:3138'git-gc' to more aggressively optimize the repository at the expense
Junio C Hamanof2ce2972007-05-20 19:12:0939of taking much more time. The effects of this optimization are
Junio C Hamano679d22d2007-06-02 21:13:4440persistent, so this option only needs to be used occasionally; every
Junio C Hamanof2ce2972007-05-20 19:12:0941few hundred changesets or so.
Junio C Hamanof65d9282007-01-22 09:00:1342
Junio C Hamano1b50ce92007-10-03 12:05:5343--auto::
Junio C Hamanoba4b9282008-07-06 05:20:3144With this option, 'git-gc' checks whether any housekeeping is
Junio C Hamano764a6672007-10-23 01:23:3145required; if not, it exits without performing any work.
46Some git commands run `git gc --auto` after performing
47operations that could create many loose objects.
48+
49Housekeeping is required if there are too many loose objects or
50too many packs in the repository. If the number of loose objects
51exceeds the value of the `gc.auto` configuration variable, then
52all loose objects are combined into a single pack using
Junio C Hamanoba4b9282008-07-06 05:20:3153'git-repack -d -l'. Setting the value of `gc.auto` to 0
Junio C Hamano764a6672007-10-23 01:23:3154disables automatic packing of loose objects.
55+
56If the number of packs exceeds the value of `gc.autopacklimit`,
57then existing packs (except those marked with a `.keep` file)
58are consolidated into a single pack by using the `-A` option of
Junio C Hamanoba4b9282008-07-06 05:20:3159'git-repack'. Setting `gc.autopacklimit` to 0 disables
Junio C Hamano764a6672007-10-23 01:23:3160automatic consolidation of packs.
Junio C Hamano1b50ce92007-10-03 12:05:5361
Junio C Hamano69a98582008-03-01 18:42:1862--quiet::
63Suppress all progress reports.
64
Junio C Hamano52299462006-12-28 00:59:3865Configuration
66-------------
67
68The optional configuration variable 'gc.reflogExpire' can be
69set to indicate how long historical entries within each branch's
70reflog should remain available in this repository. The setting is
71expressed as a length of time, for example '90 days' or '3 months'.
72It defaults to '90 days'.
73
74The optional configuration variable 'gc.reflogExpireUnreachable'
75can be set to indicate how long historical reflog entries which
76are not part of the current branch should remain available in
77this repository. These types of entries are generally created as
78a result of using `git commit \--amend` or `git rebase` and are the
Junio C Hamanof9771f62007-01-17 17:42:3079commits prior to the amend or rebase occurring. Since these changes
Junio C Hamano52299462006-12-28 00:59:3880are not part of the current project most users will want to expire
81them sooner. This option defaults to '30 days'.
82
83The optional configuration variable 'gc.rerereresolved' indicates
84how long records of conflicted merge you resolved earlier are
85kept. This defaults to 60 days.
86
87The optional configuration variable 'gc.rerereunresolved' indicates
88how long records of conflicted merge you have not resolved are
89kept. This defaults to 15 days.
90
Junio C Hamano9d52e572007-02-13 23:48:2091The optional configuration variable 'gc.packrefs' determines if
Junio C Hamanoba4b9282008-07-06 05:20:3192'git-gc' runs 'git-pack-refs'. This can be set to "nobare" to enable
Junio C Hamanoe77b0152008-01-12 06:44:1793it within all non-bare repos or it can be set to a boolean value.
94This defaults to true.
Junio C Hamano52299462006-12-28 00:59:3895
Junio C Hamanof2ce2972007-05-20 19:12:0996The optional configuration variable 'gc.aggressiveWindow' controls how
97much time is spent optimizing the delta compression of the objects in
98the repository when the --aggressive option is specified. The larger
99the value, the more time is spent optimizing the delta compression. See
Junio C Hamano35738e82008-01-07 07:55:46100the documentation for the --window' option in linkgit:git-repack[1] for
Junio C Hamanof2ce2972007-05-20 19:12:09101more details. This defaults to 10.
102
Junio C Hamano09a926d2008-03-13 07:55:29103The optional configuration variable 'gc.pruneExpire' controls how old
104the unreferenced loose objects have to be before they are pruned. The
105default is "2 weeks ago".
106
Junio C Hamano2f102bb2008-04-26 02:23:37107
108Notes
109-----
110
Junio C Hamanoba4b9282008-07-06 05:20:31111'git-gc' tries very hard to be safe about the garbage it collects. In
Junio C Hamano2f102bb2008-04-26 02:23:37112particular, it will keep not only objects referenced by your current set
113of branches and tags, but also objects referenced by the index, remote
Junio C Hamanoba4b9282008-07-06 05:20:31114tracking branches, refs saved by 'git-filter-branch' in
Junio C Hamano2f102bb2008-04-26 02:23:37115refs/original/, or reflogs (which may references commits in branches
116that were later amended or rewound).
117
118If you are expecting some objects to be collected and they aren't, check
119all of those locations and decide whether it makes sense in your case to
120remove those references.
121
Junio C Hamano9049d912008-05-29 02:09:50122SEE ALSO
Junio C Hamano52299462006-12-28 00:59:38123--------
Junio C Hamano35738e82008-01-07 07:55:46124linkgit:git-prune[1]
125linkgit:git-reflog[1]
126linkgit:git-repack[1]
127linkgit:git-rerere[1]
Junio C Hamano52299462006-12-28 00:59:38128
129Author
130------
131Written by Shawn O. Pearce <spearce@spearce.org>
132
133GIT
134---
Junio C Hamanof7c042d2008-06-06 22:50:53135Part of the linkgit:git[1] suite