37c4d26a760c8e2a0c268e6667b339e59f86617c
   1git-gc(1)
   2=========
   3
   4NAME
   5----
   6git-gc - Cleanup unnecessary files and optimize the local repository
   7
   8
   9SYNOPSIS
  10--------
  11[verse]
  12'git gc' [--aggressive] [--auto] [--quiet] [--prune=<date> | --no-prune] [--force] [--keep-largest-pack]
  13
  14DESCRIPTION
  15-----------
  16Runs a number of housekeeping tasks within the current repository,
  17such as compressing file revisions (to reduce disk space and increase
  18performance), removing unreachable objects which may have been
  19created from prior invocations of 'git add', packing refs, pruning
  20reflog, rerere metadata or stale working trees. May also update ancillary
  21indexes such as the commit-graph.
  22
  23When common porcelain operations that create objects are run, they
  24will check whether the repository has grown substantially since the
  25last maintenance, and if so run `git gc` automatically. See `gc.auto`
  26below for how to disable this behavior.
  27
  28Running `git gc` manually should only be needed when adding objects to
  29a repository without regularly running such porcelain commands, to do
  30a one-off repository optimization, or e.g. to clean up a suboptimal
  31mass-import. See the "PACKFILE OPTIMIZATION" section in
  32linkgit:git-fast-import[1] for more details on the import case.
  33
  34OPTIONS
  35-------
  36
  37--aggressive::
  38        Usually 'git gc' runs very quickly while providing good disk
  39        space utilization and performance.  This option will cause
  40        'git gc' to more aggressively optimize the repository at the expense
  41        of taking much more time.  The effects of this optimization are
  42        persistent, so this option only needs to be used occasionally; every
  43        few hundred changesets or so.
  44
  45--auto::
  46        With this option, 'git gc' checks whether any housekeeping is
  47        required; if not, it exits without performing any work.
  48+
  49See the `gc.auto` option in the "CONFIGURATION" section below for how
  50this heuristic works.
  51+
  52Once housekeeping is triggered by exceeding the limits of
  53configuration options such as `gc.auto` and `gc.autoPackLimit`, all
  54other housekeeping tasks (e.g. rerere, working trees, reflog...) will
  55be performed as well.
  56
  57
  58--prune=<date>::
  59        Prune loose objects older than date (default is 2 weeks ago,
  60        overridable by the config variable `gc.pruneExpire`).
  61        --prune=now prunes loose objects regardless of their age and
  62        increases the risk of corruption if another process is writing to
  63        the repository concurrently; see "NOTES" below. --prune is on by
  64        default.
  65
  66--no-prune::
  67        Do not prune any loose objects.
  68
  69--quiet::
  70        Suppress all progress reports.
  71
  72--force::
  73        Force `git gc` to run even if there may be another `git gc`
  74        instance running on this repository.
  75
  76--keep-largest-pack::
  77        All packs except the largest pack and those marked with a
  78        `.keep` files are consolidated into a single pack. When this
  79        option is used, `gc.bigPackThreshold` is ignored.
  80
  81CONFIGURATION
  82-------------
  83
  84The below documentation is the same as what's found in
  85linkgit:git-config[1]:
  86
  87include::config/gc.txt[]
  88
  89NOTES
  90-----
  91
  92'git gc' tries very hard not to delete objects that are referenced
  93anywhere in your repository. In
  94particular, it will keep not only objects referenced by your current set
  95of branches and tags, but also objects referenced by the index,
  96remote-tracking branches, refs saved by 'git filter-branch' in
  97refs/original/, or reflogs (which may reference commits in branches
  98that were later amended or rewound).
  99If you are expecting some objects to be deleted and they aren't, check
 100all of those locations and decide whether it makes sense in your case to
 101remove those references.
 102
 103On the other hand, when 'git gc' runs concurrently with another process,
 104there is a risk of it deleting an object that the other process is using
 105but hasn't created a reference to. This may just cause the other process
 106to fail or may corrupt the repository if the other process later adds a
 107reference to the deleted object. Git has two features that significantly
 108mitigate this problem:
 109
 110. Any object with modification time newer than the `--prune` date is kept,
 111  along with everything reachable from it.
 112
 113. Most operations that add an object to the database update the
 114  modification time of the object if it is already present so that #1
 115  applies.
 116
 117However, these features fall short of a complete solution, so users who
 118run commands concurrently have to live with some risk of corruption (which
 119seems to be low in practice) unless they turn off automatic garbage
 120collection with 'git config gc.auto 0'.
 121
 122HOOKS
 123-----
 124
 125The 'git gc --auto' command will run the 'pre-auto-gc' hook.  See
 126linkgit:githooks[5] for more information.
 127
 128
 129SEE ALSO
 130--------
 131linkgit:git-prune[1]
 132linkgit:git-reflog[1]
 133linkgit:git-repack[1]
 134linkgit:git-rerere[1]
 135
 136GIT
 137---
 138Part of the linkgit:git[1] suite