Create 'git gc' to perform common maintenance operations.
Junio asked for a 'git gc' utility which users can execute on a regular basis to perform basic repository actions such as: * pack-refs --prune * reflog expire * repack -a -d * prune * rerere gc So here is a command which does exactly that. The parameters fed to reflog's expire subcommand can be chosen by the user by setting configuration options in .git/config (or ~/.gitconfig), as users may want different expiration windows for each repository but shouldn't be bothered to remember what they are all of the time. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Shawn O. Pearce committed
Dec 27, 2006 at 02:17 UTC
30f610b7b09a579aeba343317114bf18b4fd92bf
5 files changed
+84
-1
.gitignore
+1
@@ -42,6 +42,7 @@ git-fmt-merge-msg
42
git-for-each-ref
43
git-format-patch
44
git-fsck-objects
45
+git-gc
46
git-get-tar-commit-id
47
git-grep
48
git-hash-object
Documentation/git-gc.txt
new
+64
@@ -0,0 +1,64 @@
1
+git-gc(1)
2
+=========
3
+
4
+NAME
5
+----
6
+git-gc - Cleanup unnecessary files and optimize the local repository
7
+
8
+
9
+SYNOPSIS
10
+--------
11
+'git-gc'
12
+
13
+DESCRIPTION
14
+-----------
15
+Runs a number of housekeeping tasks within the current repository,
16
+such as compressing file revisions (to reduce disk space and increase
17
+performance) and removing unreachable objects which may have been
18
+created from prior invocations of gitlink:git-add[1].
19
+
20
+Users are encouraged to run this task on a regular basis within
21
+each repository to maintain good disk space utilization and good
22
+operating performance.
23
+
24
+Configuration
25
+-------------
26
+
27
+The optional configuration variable 'gc.reflogExpire' can be
28
+set to indicate how long historical entries within each branch's
29
+reflog should remain available in this repository. The setting is
30
+expressed as a length of time, for example '90 days' or '3 months'.
31
+It defaults to '90 days'.
32
+
33
+The optional configuration variable 'gc.reflogExpireUnreachable'
34
+can be set to indicate how long historical reflog entries which
35
+are not part of the current branch should remain available in
36
+this repository. These types of entries are generally created as
37
+a result of using `git commit \--amend` or `git rebase` and are the
38
+commits prior to the amend or rebase occuring. Since these changes
39
+are not part of the current project most users will want to expire
40
+them sooner. This option defaults to '30 days'.
41
+
42
+The optional configuration variable 'gc.rerereresolved' indicates
43
+how long records of conflicted merge you resolved earlier are
44
+kept. This defaults to 60 days.
45
+
46
+The optional configuration variable 'gc.rerereunresolved' indicates
47
+how long records of conflicted merge you have not resolved are
48
+kept. This defaults to 15 days.
49
+
50
+
51
+See Also
52
+--------
53
+gitlink:git-prune[1]
54
+gitlink:git-reflog[1]
55
+gitlink:git-repack[1]
56
+gitlink:git-rerere[1]
57
+
58
+Author
59
+------
60
+Written by Shawn O. Pearce <spearce@spearce.org>
61
+
62
+GIT
63
+---
64
+Part of the gitlink:git[7] suite
Documentation/git.txt
+3
@@ -212,6 +212,9 @@ gitlink:git-cvsexportcommit[1]::
212
gitlink:git-cvsserver[1]::
213
A CVS server emulator for git.
214
215
+gitlink:git-gc[1]::
216
+ Cleanup unnecessary files and optimize the local repository.
217
+
218
gitlink:git-lost-found[1]::
219
Recover lost refs that luckily have not yet been pruned.
220
Makefile
+1
-1
@@ -157,7 +157,7 @@ BASIC_LDFLAGS =
157
SCRIPT_SH = \
158
git-bisect.sh git-checkout.sh \
159
git-clean.sh git-clone.sh git-commit.sh \
160
- git-fetch.sh \
160
+ git-fetch.sh git-gc.sh \
161
git-ls-remote.sh \
162
git-merge-one-file.sh git-parse-remote.sh \
163
git-pull.sh git-rebase.sh \
git-gc.sh
new
+15
@@ -0,0 +1,15 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2006, Shawn O. Pearce
4
+#
5
+# Cleanup unreachable files and optimize the repository.
6
+
7
+USAGE=''
8
+SUBDIRECTORY_OK=Yes
9
+. git-sh-setup
10
+
11
+git-pack-refs --prune &&
12
+git-reflog expire --all &&
13
+git-repack -a -d &&
14
+git-prune &&
15
+git-rerere gc || exit