@@ -63,11 +63,10 @@ automatic consolidation of packs.
6363--prune=<date>::
6464 Prune loose objects older than date (default is 2 weeks ago,
6565 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.
7170
7271--no-prune::
7372 Do not prune any loose objects.
@@ -138,17 +137,36 @@ default is "2 weeks ago".
138137Notes
139138-----
140139
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
142142particular, it will keep not only objects referenced by your current set
143143of branches and tags, but also objects referenced by the index,
144144remote-tracking branches, refs saved by 'git filter-branch' in
145145refs/original/, or reflogs (which may reference commits in branches
146146that 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
149148all of those locations and decide whether it makes sense in your case to
150149remove those references.
151150
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+
152170HOOKS
153171-----
154172
0 commit comments