blob: 03552dd86fc412b622aff2bcf8feda8e71711b3e [file] [log] [blame]
Junio C Hamano215a7ad2005-09-07 17:26:23 -07001git-prune(1)
2============
David Greaves2cf565c2005-05-10 22:32:30 +01003
4NAME
5----
william pursell29cf5e12007-06-09 16:44:12 +01006git-prune - Prune all unreachable objects from the object database
David Greaves2cf565c2005-05-10 22:32:30 +01007
8
9SYNOPSIS
10--------
Martin von Zweigbergk7791a1d2011-07-01 22:38:26 -040011[verse]
Robert P. J. Day1a1fc2d2017-11-21 10:51:52 -050012'git prune' [-n] [-v] [--progress] [--expire <time>] [--] [<head>...]
David Greaves2cf565c2005-05-10 22:32:30 +010013
14DESCRIPTION
15-----------
Junio C Hamanof85a4192005-08-29 17:21:06 -070016
Thomas Rast0b444cd2010-01-10 00:33:00 +010017NOTE: In most cases, users should run 'git gc', which calls
18'git prune'. See the section "NOTES", below.
Jeff King8d308b32008-04-29 16:45:14 -040019
Thomas Rast0b444cd2010-01-10 00:33:00 +010020This runs 'git fsck --unreachable' using all the refs
Jeff Kingcc1b8d82010-02-17 20:16:20 -050021available in `refs/`, optionally with additional set of
Chris Frey58949bb2008-05-14 19:22:18 -040022objects specified on the command line, and prunes all unpacked
Junio C Hamano2b869762005-12-08 23:18:41 -080023objects unreachable from any of these head objects from the object database.
24In addition, it
Junio C Hamanof85a4192005-08-29 17:21:06 -070025prunes the unpacked objects that are also found in packs by
Thomas Rast0b444cd2010-01-10 00:33:00 +010026running 'git prune-packed'.
Nguyễn Thái Ngọc Duyeab32962013-12-05 20:02:54 +070027It also removes entries from .git/shallow that are not reachable by
28any ref.
Junio C Hamanof85a4192005-08-29 17:21:06 -070029
Chris Frey58949bb2008-05-14 19:22:18 -040030Note that unreachable, packed objects will remain. If this is
31not desired, see linkgit:git-repack[1].
32
Junio C Hamanof85a4192005-08-29 17:21:06 -070033OPTIONS
34-------
35
36-n::
René Scharfe24aea032010-08-06 22:28:05 +020037--dry-run::
Junio C Hamanof85a4192005-08-29 17:21:06 -070038 Do not remove anything; just report what it would
39 remove.
David Greaves2cf565c2005-05-10 22:32:30 +010040
Michael J Gruberb35ddf42008-09-29 18:49:52 +020041-v::
René Scharfe24aea032010-08-06 22:28:05 +020042--verbose::
Michael J Gruberb35ddf42008-09-29 18:49:52 +020043 Report all removed objects.
44
Robert P. J. Day1a1fc2d2017-11-21 10:51:52 -050045--progress::
46 Show progress.
Junio C Hamanoc82365d2005-12-08 16:30:24 -080047
Stephan Beyer32402402008-06-08 03:36:09 +020048--expire <time>::
Johannes Schindelinf01913e2007-11-29 20:59:55 +000049 Only expire loose objects older than <time>.
50
Robert P. J. Day1a1fc2d2017-11-21 10:51:52 -050051\--::
52 Do not interpret any more arguments as options.
53
Junio C Hamanoc82365d2005-12-08 16:30:24 -080054<head>...::
Junio C Hamano2b869762005-12-08 23:18:41 -080055 In addition to objects
Junio C Hamanoc82365d2005-12-08 16:30:24 -080056 reachable from any of our references, keep objects
Junio C Hamano2b869762005-12-08 23:18:41 -080057 reachable from listed <head>s.
Junio C Hamanoc82365d2005-12-08 16:30:24 -080058
Nguyễn Thái Ngọc Duy76a87882018-04-30 17:35:33 +020059EXAMPLES
60--------
Junio C Hamanoc82365d2005-12-08 16:30:24 -080061
Justin Lebara58088a2014-03-31 15:11:44 -070062To prune objects not used by your repository or another that
Junio C Hamanoc82365d2005-12-08 16:30:24 -080063borrows from your repository via its
64`.git/objects/info/alternates`:
65
66------------
Jonathon Mah8c3ca722013-07-18 09:53:55 -070067$ git prune $(cd ../another && git rev-parse --all)
Junio C Hamanoc82365d2005-12-08 16:30:24 -080068------------
David Greaves2cf565c2005-05-10 22:32:30 +010069
Nguyễn Thái Ngọc Duy76a87882018-04-30 17:35:33 +020070NOTES
Jeff King8d308b32008-04-29 16:45:14 -040071-----
72
Thomas Rast0b444cd2010-01-10 00:33:00 +010073In most cases, users will not need to call 'git prune' directly, but
74should instead call 'git gc', which handles pruning along with
Jeff King8d308b32008-04-29 16:45:14 -040075many other housekeeping tasks.
76
77For a description of which objects are considered for pruning, see
Thomas Rast0b444cd2010-01-10 00:33:00 +010078'git fsck''s --unreachable option.
Jeff King8d308b32008-04-29 16:45:14 -040079
Junio C Hamano56ae8df2008-05-28 16:55:27 -070080SEE ALSO
Jeff King8d308b32008-04-29 16:45:14 -040081--------
82
83linkgit:git-fsck[1],
84linkgit:git-gc[1],
85linkgit:git-reflog[1]
86
David Greaves2cf565c2005-05-10 22:32:30 +010087GIT
88---
Christian Couder9e1f0a82008-06-06 09:07:32 +020089Part of the linkgit:git[1] suite