@@ -63,11 +63,10 @@ automatic consolidation of packs.
63
63
--prune=<date>::
64
64
Prune loose objects older than date (default is 2 weeks ago,
65
65
overridable by the config variable `gc.pruneExpire`).
66
- --prune=all prunes loose objects regardless of their age (do
67
- not use --prune=all unless you know exactly what you are doing.
68
- Unless the repository is quiescent, you will lose newly created
69
- objects that haven't been anchored with the refs and end up
70
- corrupting your repository). --prune is on by default.
66
+ --prune=all prunes loose objects regardless of their age and
67
+ increases the risk of corruption if another process is writing to
68
+ the repository concurrently; see "NOTES" below. --prune is on by
69
+ default.
71
70
72
71
--no-prune::
73
72
Do not prune any loose objects.
@@ -138,17 +137,36 @@ default is "2 weeks ago".
138
137
Notes
139
138
-----
140
139
141
- 'git gc' tries very hard to be safe about the garbage it collects. In
140
+ 'git gc' tries very hard not to delete objects that are referenced
141
+ anywhere in your repository. In
142
142
particular, it will keep not only objects referenced by your current set
143
143
of branches and tags, but also objects referenced by the index,
144
144
remote-tracking branches, refs saved by 'git filter-branch' in
145
145
refs/original/, or reflogs (which may reference commits in branches
146
146
that were later amended or rewound).
147
-
148
- If you are expecting some objects to be collected and they aren't, check
147
+ If you are expecting some objects to be deleted and they aren't, check
149
148
all of those locations and decide whether it makes sense in your case to
150
149
remove those references.
151
150
151
+ On the other hand, when 'git gc' runs concurrently with another process,
152
+ there is a risk of it deleting an object that the other process is using
153
+ but hasn't created a reference to. This may just cause the other process
154
+ to fail or may corrupt the repository if the other process later adds a
155
+ reference to the deleted object. Git has two features that significantly
156
+ mitigate this problem:
157
+
158
+ . Any object with modification time newer than the `--prune` date is kept,
159
+ along with everything reachable from it.
160
+
161
+ . Most operations that add an object to the database update the
162
+ modification time of the object if it is already present so that #1
163
+ applies.
164
+
165
+ However, these features fall short of a complete solution, so users who
166
+ run commands concurrently have to live with some risk of corruption (which
167
+ seems to be low in practice) unless they turn off automatic garbage
168
+ collection with 'git config gc.auto 0'.
169
+
152
170
HOOKS
153
171
-----
154
172
0 commit comments