CINXE.COM

Git - git-gc Documentation

<!DOCTYPE html> <html lang="en"> <head> <meta charset='utf-8'> <meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Git - git-gc Documentation</title> <link href="/favicon.ico" rel='shortcut icon' type='image/x-icon'> <link rel="stylesheet" href="/application.min.css"> <script src="/js/modernizr.js"></script> <script src="/js/modernize.js"></script> </head> <body id="documentation"> <div class="inner"> <header> <a href="/"><img src="/images/logo@2x.png" width="110" height="46" alt="Git" /></a> <span id="tagline"></span> <script type="text/javascript"> const taglines = [ "fast-version-control", "everything-is-local", "distributed-even-if-your-workflow-isnt", "local-branching-on-the-cheap", "distributed-is-the-new-centralized" ]; var tagline = taglines[Math.floor(Math.random() * taglines.length)]; document.getElementById('tagline').innerHTML = '--' + tagline; </script> <form id="search" action="/search/results"> <input id="search-text" name="search" placeholder="Type / to search entire site…" autocomplete="off" type="text" /> </form> <div id="search-results"></div> </header> </div> <div class="inner"> <div id="content-wrapper"> <div tabindex="1" class="sidebar-btn"></div> <aside class="sidebar" id="sidebar"> <nav> <ul> <li> <a href="/about">About</a> <ul> </ul> </li> <li> <a href="/doc" class="active">Documentation</a> <ul class="expanded"> <li> <a href="/docs" class="active">Reference</a> </li> <li> <a href="/book">Book</a> </li> <li> <a href="/videos">Videos</a> </li> <li> <a href="/doc/ext">External Links</a> </li> </ul> </li> <li> <a href="/downloads">Downloads</a> <ul > <li> <a href="/downloads/guis">GUI Clients</a> </li> <li> <a href="/downloads/logos">Logos</a> </li> </ul> </li> <li> <a href="/community">Community</a> </li> </ul> </nav> </aside> <div id="content"> <div id='reference-version'> <a class="dropdown-trigger" id="reference-languages-trigger" data-panel-id="l10n-versions-dropdown" href="#"> English ▾</a> <div class='dropdown-panel right' id='l10n-versions-dropdown'> <header>Localized versions of <strong>git-gc</strong> manual</header> <ol class='reference-previous-versions'> <li> <a href="/docs/git-gc"><span class="version">English</span> </a> </li> <li> <a href="/docs/git-gc/fr"><span class="version">Français</span> </a> </li> <li> <a href="/docs/git-gc/pt_BR"><span class="version">Português (Brasil)</span> </a> </li> <li> <a href="/docs/git-gc/zh_HANS-CN"><span class="version">简体中文</span> </a> </li> </ol> <footer> Want to read in your language or fix typos?<br/> <a href="https://github.com/jnavila/git-manpages-l10n">You can help translate this page</a>. </footer> </div> <a class="dropdown-trigger" id="reference-topics-trigger" data-panel-id="topics-dropdown" href="#">Topics ▾</a> <div class='dropdown-panel right' id='topics-dropdown'> <div class='three-column'> <div class='column-left'> <h3 class='setup'>Setup and Config</h3> <ul class='unstyled'> <li> <a href="/docs/git"> git </a> </li> <li> <a href="/docs/git-config"> config </a> </li> <li> <a href="/docs/git-help"> help </a> </li> <li> <a href="/docs/git-bugreport"> bugreport </a> </li> <li> <a href="/doc/credential-helpers"> Credential helpers </a> </li> </ul> <h3 class='projects'>Getting and Creating Projects</h3> <ul class='unstyled'> <li> <a href="/docs/git-init"> init </a> </li> <li> <a href="/docs/git-clone"> clone </a> </li> </ul> <h3 class='snapshotting'>Basic Snapshotting</h3> <ul class='unstyled'> <li> <a href="/docs/git-add"> add </a> </li> <li> <a href="/docs/git-status"> status </a> </li> <li> <a href="/docs/git-diff"> diff </a> </li> <li> <a href="/docs/git-commit"> commit </a> </li> <li> <a href="/docs/git-notes"> notes </a> </li> <li> <a href="/docs/git-restore"> restore </a> </li> <li> <a href="/docs/git-reset"> reset </a> </li> <li> <a href="/docs/git-rm"> rm </a> </li> <li> <a href="/docs/git-mv"> mv </a> </li> </ul> <h3 class='branching'>Branching and Merging</h3> <ul class='unstyled'> <li> <a href="/docs/git-branch"> branch </a> </li> <li> <a href="/docs/git-checkout"> checkout </a> </li> <li> <a href="/docs/git-switch"> switch </a> </li> <li> <a href="/docs/git-merge"> merge </a> </li> <li> <a href="/docs/git-mergetool"> mergetool </a> </li> <li> <a href="/docs/git-log"> log </a> </li> <li> <a href="/docs/git-stash"> stash </a> </li> <li> <a href="/docs/git-tag"> tag </a> </li> <li> <a href="/docs/git-worktree"> worktree </a> </li> </ul> <h3 class='sharing'>Sharing and Updating Projects</h3> <ul class='unstyled'> <li> <a href="/docs/git-fetch"> fetch </a> </li> <li> <a href="/docs/git-pull"> pull </a> </li> <li> <a href="/docs/git-push"> push </a> </li> <li> <a href="/docs/git-remote"> remote </a> </li> <li> <a href="/docs/git-submodule"> submodule </a> </li> </ul> </div> <div class='column-middle'> <h3 class='inspection'>Inspection and Comparison</h3> <ul class='unstyled'> <li> <a href="/docs/git-show"> show </a> </li> <li> <a href="/docs/git-log"> log </a> </li> <li> <a href="/docs/git-diff"> diff </a> </li> <li> <a href="/docs/git-difftool"> difftool </a> </li> <li> <a href="/docs/git-range-diff"> range-diff </a> </li> <li> <a href="/docs/git-shortlog"> shortlog </a> </li> <li> <a href="/docs/git-describe"> describe </a> </li> </ul> <h3 class='patching'>Patching</h3> <ul class='unstyled'> <li> <a href="/docs/git-apply"> apply </a> </li> <li> <a href="/docs/git-cherry-pick"> cherry-pick </a> </li> <li> <a href="/docs/git-diff"> diff </a> </li> <li> <a href="/docs/git-rebase"> rebase </a> </li> <li> <a href="/docs/git-revert"> revert </a> </li> </ul> <h3 class='debugging'>Debugging</h3> <ul class='unstyled'> <li> <a href="/docs/git-bisect"> bisect </a> </li> <li> <a href="/docs/git-blame"> blame </a> </li> <li> <a href="/docs/git-grep"> grep </a> </li> </ul> <h3 class='email'>Email</h3> <ul class='unstyled'> <li> <a href="/docs/git-am"> am </a> </li> <li> <a href="/docs/git-apply"> apply </a> </li> <li> <a href="/docs/git-format-patch"> format-patch </a> </li> <li> <a href="/docs/git-send-email"> send-email </a> </li> <li> <a href="/docs/git-request-pull"> request-pull </a> </li> </ul> <h3 class='external'>External Systems</h3> <ul class='unstyled'> <li> <a href="/docs/git-svn"> svn </a> </li> <li> <a href="/docs/git-fast-import"> fast-import </a> </li> </ul> <h3 class='server-admin'>Server Admin</h3> <ul class='unstyled'> <li> <a href="/docs/git-daemon"> daemon </a> </li> <li> <a href="/docs/git-update-server-info"> update-server-info </a> </li> </ul> </div> <div class='column-right'> <h3 class='guides'>Guides</h3> <ul class='unstyled'> <li> <a href="/docs/gitattributes"> gitattributes </a> </li> <li> <a href="/docs/gitcli"> Command-line interface conventions </a> </li> <li> <a href="/docs/giteveryday"> Everyday Git </a> </li> <li> <a href="/docs/gitfaq"> Frequently Asked Questions (FAQ) </a> </li> <li> <a href="/docs/gitglossary"> Glossary </a> </li> <li> <a href="/docs/githooks"> Hooks </a> </li> <li> <a href="/docs/gitignore"> gitignore </a> </li> <li> <a href="/docs/gitmodules"> gitmodules </a> </li> <li> <a href="/docs/gitrevisions"> Revisions </a> </li> <li> <a href="/docs/gitsubmodules"> Submodules </a> </li> <li> <a href="/docs/gittutorial"> Tutorial </a> </li> <li> <a href="/docs/gitworkflows"> Workflows </a> </li> <li> <a href="/docs/git#_guides"> All guides... </a> </li> </ul> <h3 class='admin'>Administration</h3> <ul class='unstyled'> <li> <a href="/docs/git-clean"> clean </a> </li> <li> <a href="/docs/git-gc"> gc </a> </li> <li> <a href="/docs/git-fsck"> fsck </a> </li> <li> <a href="/docs/git-reflog"> reflog </a> </li> <li> <a href="/docs/git-filter-branch"> filter-branch </a> </li> <li> <a href="/docs/git-instaweb"> instaweb </a> </li> <li> <a href="/docs/git-archive"> archive </a> </li> <li> <a href="/docs/git-bundle"> bundle </a> </li> </ul> <h3 class='plumbing'>Plumbing Commands</h3> <ul class='unstyled'> <li> <a href="/docs/git-cat-file"> cat-file </a> </li> <li> <a href="/docs/git-check-ignore"> check-ignore </a> </li> <li> <a href="/docs/git-checkout-index"> checkout-index </a> </li> <li> <a href="/docs/git-commit-tree"> commit-tree </a> </li> <li> <a href="/docs/git-count-objects"> count-objects </a> </li> <li> <a href="/docs/git-diff-index"> diff-index </a> </li> <li> <a href="/docs/git-for-each-ref"> for-each-ref </a> </li> <li> <a href="/docs/git-hash-object"> hash-object </a> </li> <li> <a href="/docs/git-ls-files"> ls-files </a> </li> <li> <a href="/docs/git-ls-tree"> ls-tree </a> </li> <li> <a href="/docs/git-merge-base"> merge-base </a> </li> <li> <a href="/docs/git-read-tree"> read-tree </a> </li> <li> <a href="/docs/git-rev-list"> rev-list </a> </li> <li> <a href="/docs/git-rev-parse"> rev-parse </a> </li> <li> <a href="/docs/git-show-ref"> show-ref </a> </li> <li> <a href="/docs/git-symbolic-ref"> symbolic-ref </a> </li> <li> <a href="/docs/git-update-index"> update-index </a> </li> <li> <a href="/docs/git-update-ref"> update-ref </a> </li> <li> <a href="/docs/git-verify-pack"> verify-pack </a> </li> <li> <a href="/docs/git-write-tree"> write-tree </a> </li> </ul> </div> </div> </div> <a class="dropdown-trigger" id="reference-versions-trigger" data-panel-id="previous-versions-dropdown" href="#"> Latest version ▾ </a> <span class="light d-flex">git-gc last updated in 2.47.0</span> <div class='dropdown-panel left' id='previous-versions-dropdown'> <header>Changes in the <strong>git-gc</strong> manual</header> <ol class='reference-previous-versions'> <li> <a href="/docs/git-gc/2.47.0"><span class="version">2.47.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">10/06/24</em> </a> </li> <li class="no-change"><span>2.43.1 &rarr; 2.46.2 no changes</span></li> <li> <a href="/docs/git-gc/2.43.0"><span class="version">2.43.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">11/20/23</em> </a> </li> <li class="no-change"><span>2.42.1 &rarr; 2.42.3 no changes</span></li> <li> <a href="/docs/git-gc/2.42.0"><span class="version">2.42.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">08/21/23</em> </a> </li> <li class="no-change"><span>2.41.1 &rarr; 2.41.2 no changes</span></li> <li> <a href="/docs/git-gc/2.41.0"><span class="version">2.41.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">06/01/23</em> </a> </li> <li class="no-change"><span>2.38.1 &rarr; 2.40.3 no changes</span></li> <li> <a href="/docs/git-gc/2.38.0"><span class="version">2.38.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">10/02/22</em> </a> </li> <li class="no-change"><span>2.37.1 &rarr; 2.37.7 no changes</span></li> <li> <a href="/docs/git-gc/2.37.0"><span class="version">2.37.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">06/27/22</em> </a> </li> <li class="no-change"><span>2.31.1 &rarr; 2.36.6 no changes</span></li> <li> <a href="/docs/git-gc/2.31.0"><span class="version">2.31.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">03/15/21</em> </a> </li> <li class="no-change"><span>2.30.1 &rarr; 2.30.9 no changes</span></li> <li> <a href="/docs/git-gc/2.30.0"><span class="version">2.30.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">12/27/20</em> </a> </li> <li class="no-change"><span>2.24.1 &rarr; 2.29.3 no changes</span></li> <li> <a href="/docs/git-gc/2.24.0"><span class="version">2.24.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">11/04/19</em> </a> </li> <li class="no-change"><span>2.22.1 &rarr; 2.23.4 no changes</span></li> <li> <a href="/docs/git-gc/2.22.0"><span class="version">2.22.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">06/07/19</em> </a> </li> <li class="no-change"><span>2.21.1 &rarr; 2.21.4 no changes</span></li> <li> <a href="/docs/git-gc/2.21.0"><span class="version">2.21.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">02/24/19</em> </a> </li> <li class="no-change"><span>2.20.1 &rarr; 2.20.5 no changes</span></li> <li> <a href="/docs/git-gc/2.20.0"><span class="version">2.20.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">12/09/18</em> </a> </li> <li class="no-change"><span>2.19.1 &rarr; 2.19.6 no changes</span></li> <li> <a href="/docs/git-gc/2.19.0"><span class="version">2.19.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">09/10/18</em> </a> </li> <li class="no-change"><span>2.18.1 &rarr; 2.18.5 no changes</span></li> <li> <a href="/docs/git-gc/2.18.0"><span class="version">2.18.0</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">06/21/18</em> </a> </li> <li class="no-change"><span>2.13.7 &rarr; 2.17.6 no changes</span></li> <li> <a href="/docs/git-gc/2.12.5"><span class="version">2.12.5</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">09/22/17</em> </a> </li> <li> <a href="/docs/git-gc/2.11.4"><span class="version">2.11.4</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">09/22/17</em> </a> </li> <li class="no-change"><span>2.10.5 no changes</span></li> <li> <a href="/docs/git-gc/2.9.5"><span class="version">2.9.5</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">07/30/17</em> </a> </li> <li class="no-change"><span>2.7.6 &rarr; 2.8.6 no changes</span></li> <li> <a href="/docs/git-gc/2.6.7"><span class="version">2.6.7</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">05/05/17</em> </a> </li> <li class="no-change"><span>2.5.6 no changes</span></li> <li> <a href="/docs/git-gc/2.4.12"><span class="version">2.4.12</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">05/05/17</em> </a> </li> <li class="no-change"><span>2.1.4 &rarr; 2.3.10 no changes</span></li> <li> <a href="/docs/git-gc/2.0.5"><span class="version">2.0.5</span> <span class="diff"> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/green-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/red-dot.png" /> <img src="/images/icons/grey-dot.png" /> <img src="/images/icons/grey-dot.png" /> </span> <em class="date">12/17/14</em> </a> </li> <li>&nbsp;</li> </ol> <footer> <p>Check your version of git by running</p> <code class="command">git --version</code> </footer> </div> </div> <div id="main" data-pagefind-filter="category:reference" data-pagefind-meta="category:Reference" data-pagefind-weight="0.05" data-pagefind-body> <div class="sect1"> <h2 id="_name"><a class="anchor" href="#_name"></a>NAME</h2> <div class="sectionbody"> <div class="paragraph"> <p>git-gc - Cleanup unnecessary files and optimize the local repository</p> </div> </div> </div> <div class="sect1"> <h2 id="_synopsis"><a class="anchor" href="#_synopsis"></a>SYNOPSIS</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content"><em>git gc</em> [--aggressive] [--auto] [--[no-]detach] [--quiet] [--prune=&lt;date&gt; | --no-prune] [--force] [--keep-largest-pack]</pre> </div> </div> </div> <div class="sect1"> <h2 id="_description"><a class="anchor" href="#_description"></a>DESCRIPTION</h2> <div class="sectionbody"> <div class="paragraph"> <p>Runs a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance), removing unreachable objects which may have been created from prior invocations of <em>git add</em>, packing refs, pruning reflog, rerere metadata or stale working trees. May also update ancillary indexes such as the commit-graph.</p> </div> <div class="paragraph"> <p>When common porcelain operations that create objects are run, they will check whether the repository has grown substantially since the last maintenance, and if so run <code>git gc</code> automatically. See <code>gc.auto</code> below for how to disable this behavior.</p> </div> <div class="paragraph"> <p>Running <code>git gc</code> manually should only be needed when adding objects to a repository without regularly running such porcelain commands, to do a one-off repository optimization, or e.g. to clean up a suboptimal mass-import. See the "PACKFILE OPTIMIZATION" section in <a href='/docs/git-fast-import'>git-fast-import[1]</a> for more details on the import case.</p> </div> </div> </div> <div class="sect1"> <h2 id="_options"><a class="anchor" href="#_options"></a>OPTIONS</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-gc.txt---aggressive"> <a class="anchor" href="#Documentation/git-gc.txt---aggressive"></a>--aggressive </dt> <dd> <p>Usually <em>git gc</em> runs very quickly while providing good disk space utilization and performance. This option will cause <em>git gc</em> to more aggressively optimize the repository at the expense of taking much more time. The effects of this optimization are mostly persistent. See the "AGGRESSIVE" section below for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---auto"> <a class="anchor" href="#Documentation/git-gc.txt---auto"></a>--auto </dt> <dd> <p>With this option, <em>git gc</em> checks whether any housekeeping is required; if not, it exits without performing any work.</p> <div class="paragraph"> <p>See the <code>gc.auto</code> option in the "CONFIGURATION" section below for how this heuristic works.</p> </div> <div class="paragraph"> <p>Once housekeeping is triggered by exceeding the limits of configuration options such as <code>gc.auto</code> and <code>gc.autoPackLimit</code>, all other housekeeping tasks (e.g. rerere, working trees, reflog&#8230;&#8203;) will be performed as well.</p> </div> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---no-detach"> <a class="anchor" href="#Documentation/git-gc.txt---no-detach"></a>--[no-]detach </dt> <dd> <p>Run in the background if the system supports it. This option overrides the <code>gc.autoDetach</code> config.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---no-cruft"> <a class="anchor" href="#Documentation/git-gc.txt---no-cruft"></a>--[no-]cruft </dt> <dd> <p>When expiring unreachable objects, pack them separately into a cruft pack instead of storing them as loose objects. <code>--cruft</code> is on by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---max-cruft-sizeltngt"> <a class="anchor" href="#Documentation/git-gc.txt---max-cruft-sizeltngt"></a>--max-cruft-size=&lt;n&gt; </dt> <dd> <p>When packing unreachable objects into a cruft pack, limit the size of new cruft packs to be at most <code>&lt;n&gt;</code> bytes. Overrides any value specified via the <code>gc.maxCruftSize</code> configuration. See the <code>--max-cruft-size</code> option of <a href='/docs/git-repack'>git-repack[1]</a> for more.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---pruneltdategt"> <a class="anchor" href="#Documentation/git-gc.txt---pruneltdategt"></a>--prune=&lt;date&gt; </dt> <dd> <p>Prune loose objects older than date (default is 2 weeks ago, overridable by the config variable <code>gc.pruneExpire</code>). --prune=now prunes loose objects regardless of their age and increases the risk of corruption if another process is writing to the repository concurrently; see "NOTES" below. --prune is on by default.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---no-prune"> <a class="anchor" href="#Documentation/git-gc.txt---no-prune"></a>--no-prune </dt> <dd> <p>Do not prune any loose objects.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---quiet"> <a class="anchor" href="#Documentation/git-gc.txt---quiet"></a>--quiet </dt> <dd> <p>Suppress all progress reports.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---force"> <a class="anchor" href="#Documentation/git-gc.txt---force"></a>--force </dt> <dd> <p>Force <code>git gc</code> to run even if there may be another <code>git gc</code> instance running on this repository.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt---keep-largest-pack"> <a class="anchor" href="#Documentation/git-gc.txt---keep-largest-pack"></a>--keep-largest-pack </dt> <dd> <p>All packs except the largest non-cruft pack, any packs marked with a <code>.keep</code> file, and any cruft pack(s) are consolidated into a single pack. When this option is used, <code>gc.bigPackThreshold</code> is ignored.</p> </dd> </dl> </div> </div> </div> <div class="sect1"> <h2 id="_aggressive"><a class="anchor" href="#_aggressive"></a>AGGRESSIVE</h2> <div class="sectionbody"> <div class="paragraph"> <p>When the <code>--aggressive</code> option is supplied, <a href='/docs/git-repack'>git-repack[1]</a> will be invoked with the <code>-f</code> flag, which in turn will pass <code>--no-reuse-delta</code> to <a href='/docs/git-pack-objects'>git-pack-objects[1]</a>. This will throw away any existing deltas and re-compute them, at the expense of spending much more time on the repacking.</p> </div> <div class="paragraph"> <p>The effects of this are mostly persistent, e.g. when packs and loose objects are coalesced into one another pack the existing deltas in that pack might get re-used, but there are also various cases where we might pick a sub-optimal delta from a newer pack instead.</p> </div> <div class="paragraph"> <p>Furthermore, supplying <code>--aggressive</code> will tweak the <code>--depth</code> and <code>--window</code> options passed to <a href='/docs/git-repack'>git-repack[1]</a>. See the <code>gc.aggressiveDepth</code> and <code>gc.aggressiveWindow</code> settings below. By using a larger window size we&#8217;re more likely to find more optimal deltas.</p> </div> <div class="paragraph"> <p>It&#8217;s probably not worth it to use this option on a given repository without running tailored performance benchmarks on it. It takes a lot more time, and the resulting space/delta optimization may or may not be worth it. Not using this at all is the right trade-off for most users and their repositories.</p> </div> </div> </div> <div class="sect1"> <h2 id="_configuration"><a class="anchor" href="#_configuration"></a>CONFIGURATION</h2> <div class="sectionbody"> <div class="paragraph"> <p>Everything below this line in this section is selectively included from the <a href='/docs/git-config'>git-config[1]</a> documentation. The content is the same as what&#8217;s found there:</p> </div> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-gc.txt-gcaggressiveDepth"> <a class="anchor" href="#Documentation/git-gc.txt-gcaggressiveDepth"></a>gc.aggressiveDepth </dt> <dd> <p>The depth parameter used in the delta compression algorithm used by <em>git gc --aggressive</em>. This defaults to 50, which is the default for the <code>--depth</code> option when <code>--aggressive</code> isn&#8217;t in use.</p> <div class="paragraph"> <p>See the documentation for the <code>--depth</code> option in <a href='/docs/git-repack'>git-repack[1]</a> for more details.</p> </div> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcaggressiveWindow"> <a class="anchor" href="#Documentation/git-gc.txt-gcaggressiveWindow"></a>gc.aggressiveWindow </dt> <dd> <p>The window size parameter used in the delta compression algorithm used by <em>git gc --aggressive</em>. This defaults to 250, which is a much more aggressive window size than the default <code>--window</code> of 10.</p> <div class="paragraph"> <p>See the documentation for the <code>--window</code> option in <a href='/docs/git-repack'>git-repack[1]</a> for more details.</p> </div> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcauto"> <a class="anchor" href="#Documentation/git-gc.txt-gcauto"></a>gc.auto </dt> <dd> <p>When there are approximately more than this many loose objects in the repository, <code>git gc --auto</code> will pack them. Some Porcelain commands use this command to perform a light-weight garbage collection from time to time. The default value is 6700.</p> <div class="paragraph"> <p>Setting this to 0 disables not only automatic packing based on the number of loose objects, but also any other heuristic <code>git gc --auto</code> will otherwise use to determine if there&#8217;s work to do, such as <code>gc.autoPackLimit</code>.</p> </div> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcautoPackLimit"> <a class="anchor" href="#Documentation/git-gc.txt-gcautoPackLimit"></a>gc.autoPackLimit </dt> <dd> <p>When there are more than this many packs that are not marked with <code>*.keep</code> file in the repository, <code>git gc --auto</code> consolidates them into one larger pack. The default value is 50. Setting this to 0 disables it. Setting <code>gc.auto</code> to 0 will also disable this.</p> <div class="paragraph"> <p>See the <code>gc.bigPackThreshold</code> configuration variable below. When in use, it&#8217;ll affect how the auto pack limit works.</p> </div> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcautoDetach"> <a class="anchor" href="#Documentation/git-gc.txt-gcautoDetach"></a>gc.autoDetach </dt> <dd> <p>Make <code>git gc --auto</code> return immediately and run in the background if the system supports it. Default is true. This config variable acts as a fallback in case <code>maintenance.autoDetach</code> is not set.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcbigPackThreshold"> <a class="anchor" href="#Documentation/git-gc.txt-gcbigPackThreshold"></a>gc.bigPackThreshold </dt> <dd> <p>If non-zero, all non-cruft packs larger than this limit are kept when <code>git gc</code> is run. This is very similar to <code>--keep-largest-pack</code> except that all non-cruft packs that meet the threshold are kept, not just the largest pack. Defaults to zero. Common unit suffixes of <em>k</em>, <em>m</em>, or <em>g</em> are supported.</p> <div class="paragraph"> <p>Note that if the number of kept packs is more than gc.autoPackLimit, this configuration variable is ignored, all packs except the base pack will be repacked. After this the number of packs should go below gc.autoPackLimit and gc.bigPackThreshold should be respected again.</p> </div> <div class="paragraph"> <p>If the amount of memory estimated for <code>git repack</code> to run smoothly is not available and <code>gc.bigPackThreshold</code> is not set, the largest pack will also be excluded (this is the equivalent of running <code>git gc</code> with <code>--keep-largest-pack</code>).</p> </div> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcwriteCommitGraph"> <a class="anchor" href="#Documentation/git-gc.txt-gcwriteCommitGraph"></a>gc.writeCommitGraph </dt> <dd> <p>If true, then gc will rewrite the commit-graph file when <a href='/docs/git-gc'>git-gc[1]</a> is run. When using <code>git gc --auto</code> the commit-graph will be updated if housekeeping is required. Default is true. See <a href='/docs/git-commit-graph'>git-commit-graph[1]</a> for details.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gclogExpiry"> <a class="anchor" href="#Documentation/git-gc.txt-gclogExpiry"></a>gc.logExpiry </dt> <dd> <p>If the file gc.log exists, then <code>git gc --auto</code> will print its content and exit with status zero instead of running unless that file is more than <em>gc.logExpiry</em> old. Default is "1.day". See <code>gc.pruneExpire</code> for more ways to specify its value.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcpackRefs"> <a class="anchor" href="#Documentation/git-gc.txt-gcpackRefs"></a>gc.packRefs </dt> <dd> <p>Running <code>git pack-refs</code> in a repository renders it unclonable by Git versions prior to 1.5.1.2 over dumb transports such as HTTP. This variable determines whether <em>git gc</em> runs <code>git pack-refs</code>. This can be set to <code>notbare</code> to enable it within all non-bare repos or it can be set to a boolean value. The default is <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gccruftPacks"> <a class="anchor" href="#Documentation/git-gc.txt-gccruftPacks"></a>gc.cruftPacks </dt> <dd> <p>Store unreachable objects in a cruft pack (see <a href='/docs/git-repack'>git-repack[1]</a>) instead of as loose objects. The default is <code>true</code>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcmaxCruftSize"> <a class="anchor" href="#Documentation/git-gc.txt-gcmaxCruftSize"></a>gc.maxCruftSize </dt> <dd> <p>Limit the size of new cruft packs when repacking. When specified in addition to <code>--max-cruft-size</code>, the command line option takes priority. See the <code>--max-cruft-size</code> option of <a href='/docs/git-repack'>git-repack[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcpruneExpire"> <a class="anchor" href="#Documentation/git-gc.txt-gcpruneExpire"></a>gc.pruneExpire </dt> <dd> <p>When <em>git gc</em> is run, it will call <em>prune --expire 2.weeks.ago</em> (and <em>repack --cruft --cruft-expiration 2.weeks.ago</em> if using cruft packs via <code>gc.cruftPacks</code> or <code>--cruft</code>). Override the grace period with this config variable. The value "now" may be used to disable this grace period and always prune unreachable objects immediately, or "never" may be used to suppress pruning. This feature helps prevent corruption when <em>git gc</em> runs concurrently with another process writing to the repository; see the "NOTES" section of <a href='/docs/git-gc'>git-gc[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcworktreePruneExpire"> <a class="anchor" href="#Documentation/git-gc.txt-gcworktreePruneExpire"></a>gc.worktreePruneExpire </dt> <dd> <p>When <em>git gc</em> is run, it calls <em>git worktree prune --expire 3.months.ago</em>. This config variable can be used to set a different grace period. The value "now" may be used to disable the grace period and prune <code>$GIT_DIR/worktrees</code> immediately, or "never" may be used to suppress pruning.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcreflogExpire"> <a class="anchor" href="#Documentation/git-gc.txt-gcreflogExpire"></a>gc.reflogExpire </dt> <dt class="hdlist1" id="Documentation/git-gc.txt-gcltpatterngtreflogExpire"> <a class="anchor" href="#Documentation/git-gc.txt-gcltpatterngtreflogExpire"></a>gc.&lt;pattern&gt;.reflogExpire </dt> <dd> <p><em>git reflog expire</em> removes reflog entries older than this time; defaults to 90 days. The value "now" expires all entries immediately, and "never" suppresses expiration altogether. With "&lt;pattern&gt;" (e.g. "refs/stash") in the middle the setting applies only to the refs that match the &lt;pattern&gt;.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcreflogExpireUnreachable"> <a class="anchor" href="#Documentation/git-gc.txt-gcreflogExpireUnreachable"></a>gc.reflogExpireUnreachable </dt> <dt class="hdlist1" id="Documentation/git-gc.txt-gcltpatterngtreflogExpireUnreachable"> <a class="anchor" href="#Documentation/git-gc.txt-gcltpatterngtreflogExpireUnreachable"></a>gc.&lt;pattern&gt;.reflogExpireUnreachable </dt> <dd> <p><em>git reflog expire</em> removes reflog entries older than this time and are not reachable from the current tip; defaults to 30 days. The value "now" expires all entries immediately, and "never" suppresses expiration altogether. With "&lt;pattern&gt;" (e.g. "refs/stash") in the middle, the setting applies only to the refs that match the &lt;pattern&gt;.</p> <div class="paragraph"> <p>These types of entries are generally created as a result of using <code>git commit --amend</code> or <code>git rebase</code> and are the commits prior to the amend or rebase occurring. Since these changes are not part of the current project most users will want to expire them sooner, which is why the default is more aggressive than <code>gc.reflogExpire</code>.</p> </div> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcrecentObjectsHook"> <a class="anchor" href="#Documentation/git-gc.txt-gcrecentObjectsHook"></a>gc.recentObjectsHook </dt> <dd> <p>When considering whether or not to remove an object (either when generating a cruft pack or storing unreachable objects as loose), use the shell to execute the specified command(s). Interpret their output as object IDs which Git will consider as "recent", regardless of their age. By treating their mtimes as "now", any objects (and their descendants) mentioned in the output will be kept regardless of their true age.</p> <div class="paragraph"> <p>Output must contain exactly one hex object ID per line, and nothing else. Objects which cannot be found in the repository are ignored. Multiple hooks are supported, but all must exit successfully, else the operation (either generating a cruft pack or unpacking unreachable objects) will be halted.</p> </div> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcrepackFilter"> <a class="anchor" href="#Documentation/git-gc.txt-gcrepackFilter"></a>gc.repackFilter </dt> <dd> <p>When repacking, use the specified filter to move certain objects into a separate packfile. See the <code>--filter=&lt;filter-spec&gt;</code> option of <a href='/docs/git-repack'>git-repack[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcrepackFilterTo"> <a class="anchor" href="#Documentation/git-gc.txt-gcrepackFilterTo"></a>gc.repackFilterTo </dt> <dd> <p>When repacking and using a filter, see <code>gc.repackFilter</code>, the specified location will be used to create the packfile containing the filtered out objects. <strong>WARNING:</strong> The specified location should be accessible, using for example the Git alternates mechanism, otherwise the repo could be considered corrupt by Git as it might not be able to access the objects in that packfile. See the <code>--filter-to=&lt;dir&gt;</code> option of <a href='/docs/git-repack'>git-repack[1]</a> and the <code>objects/info/alternates</code> section of <a href='/docs/gitrepository-layout'>gitrepository-layout[5]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcrerereResolved"> <a class="anchor" href="#Documentation/git-gc.txt-gcrerereResolved"></a>gc.rerereResolved </dt> <dd> <p>Records of conflicted merge you resolved earlier are kept for this many days when <em>git rerere gc</em> is run. You can also use more human-readable "1.month.ago", etc. The default is 60 days. See <a href='/docs/git-rerere'>git-rerere[1]</a>.</p> </dd> <dt class="hdlist1" id="Documentation/git-gc.txt-gcrerereUnresolved"> <a class="anchor" href="#Documentation/git-gc.txt-gcrerereUnresolved"></a>gc.rerereUnresolved </dt> <dd> <p>Records of conflicted merge you have not resolved are kept for this many days when <em>git rerere gc</em> is run. You can also use more human-readable "1.month.ago", etc. The default is 15 days. See <a href='/docs/git-rerere'>git-rerere[1]</a>.</p> </dd> </dl> </div> </div> </div> <div class="sect1"> <h2 id="_notes"><a class="anchor" href="#_notes"></a>NOTES</h2> <div class="sectionbody"> <div class="paragraph"> <p><em>git gc</em> tries very hard not to delete objects that are referenced anywhere in your repository. In particular, it will keep not only objects referenced by your current set of branches and tags, but also objects referenced by the index, remote-tracking branches, reflogs (which may reference commits in branches that were later amended or rewound), and anything else in the refs/* namespace. Note that a note (of the kind created by <em>git notes</em>) attached to an object does not contribute in keeping the object alive. If you are expecting some objects to be deleted and they aren&#8217;t, check all of those locations and decide whether it makes sense in your case to remove those references.</p> </div> <div class="paragraph"> <p>On the other hand, when <em>git gc</em> runs concurrently with another process, there is a risk of it deleting an object that the other process is using but hasn&#8217;t created a reference to. This may just cause the other process to fail or may corrupt the repository if the other process later adds a reference to the deleted object. Git has two features that significantly mitigate this problem:</p> </div> <div class="olist arabic"> <ol class="arabic"> <li> <p>Any object with modification time newer than the <code>--prune</code> date is kept, along with everything reachable from it.</p> </li> <li> <p>Most operations that add an object to the database update the modification time of the object if it is already present so that #1 applies.</p> </li> </ol> </div> <div class="paragraph"> <p>However, these features fall short of a complete solution, so users who run commands concurrently have to live with some risk of corruption (which seems to be low in practice).</p> </div> </div> </div> <div class="sect1"> <h2 id="_hooks"><a class="anchor" href="#_hooks"></a>HOOKS</h2> <div class="sectionbody"> <div class="paragraph"> <p>The <em>git gc --auto</em> command will run the <em>pre-auto-gc</em> hook. See <a href='/docs/githooks'>githooks[5]</a> for more information.</p> </div> </div> </div> <div class="sect1"> <h2 id="_see_also"><a class="anchor" href="#_see_also"></a>SEE ALSO</h2> <div class="sectionbody"> <div class="paragraph"> <p><a href='/docs/git-prune'>git-prune[1]</a> <a href='/docs/git-reflog'>git-reflog[1]</a> <a href='/docs/git-repack'>git-repack[1]</a> <a href='/docs/git-rerere'>git-rerere[1]</a></p> </div> </div> </div> <div class="sect1"> <h2 id="_git"><a class="anchor" href="#_git"></a>GIT</h2> <div class="sectionbody"> <div class="paragraph"> <p>Part of the <a href='/docs/git'>git[1]</a> suite</p> </div> </div> </div> <h3 hidden="true" data-pagefind-weight="10">gc</h3> </div> </div> </div> <footer> <div class="site-source"> <a href="/site">About this site</a><br> Patches, suggestions, and comments are welcome. </div> <div class="sfc-member"> Git is a member of <a href="/sfc">Software Freedom Conservancy</a> </div> </footer> <a href="#top" class="no-js scrollToTop" id="scrollToTop" data-label="Scroll to top"> <img src="/images/icons/chevron-up@2x.png" width="20" height="20" alt="scroll-to-top"/> </a> <script src="/js/jquery-1.7.1.min.js"></script> <script src="/js/jquery-ui-1.8.18.custom.min.js"></script> <script src="/js/jquery.defaultvalue.js"></script> <script src="/js/session.min.js"></script> <script src="/js/application.min.js"></script> </div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10