1GIT-PACK-OBJECTS(1) Git Manual GIT-PACK-OBJECTS(1)
2
3
4
6 git-pack-objects - Create a packed archive of objects
7
9 git pack-objects [-q | --progress | --all-progress] [--all-progress-implied]
10 [--no-reuse-delta] [--delta-base-offset] [--non-empty]
11 [--local] [--incremental] [--window=<n>] [--depth=<n>]
12 [--revs [--unpacked | --all]] [--keep-pack=<pack-name>]
13 [--stdout [--filter=<filter-spec>] | base-name]
14 [--shallow] [--keep-true-parents] < object-list
15
16
18 Reads list of objects from the standard input, and writes either one or
19 more packed archives with the specified base-name to disk, or a packed
20 archive to the standard output.
21
22 A packed archive is an efficient way to transfer a set of objects
23 between two repositories as well as an access efficient archival
24 format. In a packed archive, an object is either stored as a compressed
25 whole or as a difference from some other object. The latter is often
26 called a delta.
27
28 The packed archive format (.pack) is designed to be self-contained so
29 that it can be unpacked without any further information. Therefore,
30 each object that a delta depends upon must be present within the pack.
31
32 A pack index file (.idx) is generated for fast, random access to the
33 objects in the pack. Placing both the index file (.idx) and the packed
34 archive (.pack) in the pack/ subdirectory of $GIT_OBJECT_DIRECTORY (or
35 any of the directories on $GIT_ALTERNATE_OBJECT_DIRECTORIES) enables
36 Git to read from the pack archive.
37
38 The git unpack-objects command can read the packed archive and expand
39 the objects contained in the pack into "one-file one-object" format;
40 this is typically done by the smart-pull commands when a pack is
41 created on-the-fly for efficient network transport by their peers.
42
44 base-name
45 Write into pairs of files (.pack and .idx), using <base-name> to
46 determine the name of the created file. When this option is used,
47 the two files in a pair are written in
48 <base-name>-<SHA-1>.{pack,idx} files. <SHA-1> is a hash based on
49 the pack content and is written to the standard output of the
50 command.
51
52 --stdout
53 Write the pack contents (what would have been written to .pack
54 file) out to the standard output.
55
56 --revs
57 Read the revision arguments from the standard input, instead of
58 individual object names. The revision arguments are processed the
59 same way as git rev-list with the --objects flag uses its commit
60 arguments to build the list of objects it outputs. The objects on
61 the resulting list are packed. Besides revisions, --not or
62 --shallow <SHA-1> lines are also accepted.
63
64 --unpacked
65 This implies --revs. When processing the list of revision arguments
66 read from the standard input, limit the objects packed to those
67 that are not already packed.
68
69 --all
70 This implies --revs. In addition to the list of revision arguments
71 read from the standard input, pretend as if all refs under refs/
72 are specified to be included.
73
74 --include-tag
75 Include unasked-for annotated tags if the object they reference was
76 included in the resulting packfile. This can be useful to send new
77 tags to native Git clients.
78
79 --window=<n>, --depth=<n>
80 These two options affect how the objects contained in the pack are
81 stored using delta compression. The objects are first internally
82 sorted by type, size and optionally names and compared against the
83 other objects within --window to see if using delta compression
84 saves space. --depth limits the maximum delta depth; making it too
85 deep affects the performance on the unpacker side, because delta
86 data needs to be applied that many times to get to the necessary
87 object.
88
89 The default value for --window is 10 and --depth is 50. The maximum
90 depth is 4095.
91
92 --window-memory=<n>
93 This option provides an additional limit on top of --window; the
94 window size will dynamically scale down so as to not take up more
95 than <n> bytes in memory. This is useful in repositories with a mix
96 of large and small objects to not run out of memory with a large
97 window, but still be able to take advantage of the large window for
98 the smaller objects. The size can be suffixed with "k", "m", or
99 "g". --window-memory=0 makes memory usage unlimited. The default
100 is taken from the pack.windowMemory configuration variable.
101
102 --max-pack-size=<n>
103 In unusual scenarios, you may not be able to create files larger
104 than a certain size on your filesystem, and this option can be used
105 to tell the command to split the output packfile into multiple
106 independent packfiles, each not larger than the given size. The
107 size can be suffixed with "k", "m", or "g". The minimum size
108 allowed is limited to 1 MiB. This option prevents the creation of a
109 bitmap index. The default is unlimited, unless the config variable
110 pack.packSizeLimit is set.
111
112 --honor-pack-keep
113 This flag causes an object already in a local pack that has a .keep
114 file to be ignored, even if it would have otherwise been packed.
115
116 --keep-pack=<pack-name>
117 This flag causes an object already in the given pack to be ignored,
118 even if it would have otherwise been packed. <pack-name> is the
119 the pack file name without leading directory (e.g. pack-123.pack).
120 The option could be specified multiple times to keep multiple
121 packs.
122
123 --incremental
124 This flag causes an object already in a pack to be ignored even if
125 it would have otherwise been packed.
126
127 --local
128 This flag causes an object that is borrowed from an alternate
129 object store to be ignored even if it would have otherwise been
130 packed.
131
132 --non-empty
133 Only create a packed archive if it would contain at least one
134 object.
135
136 --progress
137 Progress status is reported on the standard error stream by default
138 when it is attached to a terminal, unless -q is specified. This
139 flag forces progress status even if the standard error stream is
140 not directed to a terminal.
141
142 --all-progress
143 When --stdout is specified then progress report is displayed during
144 the object count and compression phases but inhibited during the
145 write-out phase. The reason is that in some cases the output stream
146 is directly linked to another command which may wish to display
147 progress status of its own as it processes incoming pack data. This
148 flag is like --progress except that it forces progress report for
149 the write-out phase as well even if --stdout is used.
150
151 --all-progress-implied
152 This is used to imply --all-progress whenever progress display is
153 activated. Unlike --all-progress this flag doesn’t actually force
154 any progress display by itself.
155
156 -q
157 This flag makes the command not to report its progress on the
158 standard error stream.
159
160 --no-reuse-delta
161 When creating a packed archive in a repository that has existing
162 packs, the command reuses existing deltas. This sometimes results
163 in a slightly suboptimal pack. This flag tells the command not to
164 reuse existing deltas but compute them from scratch.
165
166 --no-reuse-object
167 This flag tells the command not to reuse existing object data at
168 all, including non deltified object, forcing recompression of
169 everything. This implies --no-reuse-delta. Useful only in the
170 obscure case where wholesale enforcement of a different compression
171 level on the packed data is desired.
172
173 --compression=<n>
174 Specifies compression level for newly-compressed data in the
175 generated pack. If not specified, pack compression level is
176 determined first by pack.compression, then by core.compression, and
177 defaults to -1, the zlib default, if neither is set. Add
178 --no-reuse-object if you want to force a uniform compression level
179 on all data no matter the source.
180
181 --thin
182 Create a "thin" pack by omitting the common objects between a
183 sender and a receiver in order to reduce network transfer. This
184 option only makes sense in conjunction with --stdout.
185
186 Note: A thin pack violates the packed archive format by omitting
187 required objects and is thus unusable by Git without making it
188 self-contained. Use git index-pack --fix-thin (see git-index-
189 pack(1)) to restore the self-contained property.
190
191 --shallow
192 Optimize a pack that will be provided to a client with a shallow
193 repository. This option, combined with --thin, can result in a
194 smaller pack at the cost of speed.
195
196 --delta-base-offset
197 A packed archive can express the base object of a delta as either a
198 20-byte object name or as an offset in the stream, but ancient
199 versions of Git don’t understand the latter. By default, git
200 pack-objects only uses the former format for better compatibility.
201 This option allows the command to use the latter format for
202 compactness. Depending on the average delta chain length, this
203 option typically shrinks the resulting packfile by 3-5 per-cent.
204
205 Note: Porcelain commands such as git gc (see git-gc(1)), git repack
206 (see git-repack(1)) pass this option by default in modern Git when
207 they put objects in your repository into pack files. So does git
208 bundle (see git-bundle(1)) when it creates a bundle.
209
210 --threads=<n>
211 Specifies the number of threads to spawn when searching for best
212 delta matches. This requires that pack-objects be compiled with
213 pthreads otherwise this option is ignored with a warning. This is
214 meant to reduce packing time on multiprocessor machines. The
215 required amount of memory for the delta search window is however
216 multiplied by the number of threads. Specifying 0 will cause Git to
217 auto-detect the number of CPU’s and set the number of threads
218 accordingly.
219
220 --index-version=<version>[,<offset>]
221 This is intended to be used by the test suite only. It allows to
222 force the version for the generated pack index, and to force 64-bit
223 index entries on objects located above the given offset.
224
225 --keep-true-parents
226 With this option, parents that are hidden by grafts are packed
227 nevertheless.
228
229 --filter=<filter-spec>
230 Requires --stdout. Omits certain objects (usually blobs) from the
231 resulting packfile. See git-rev-list(1) for valid <filter-spec>
232 forms.
233
234 --no-filter
235 Turns off any previous --filter= argument.
236
237 --missing=<missing-action>
238 A debug option to help with future "partial clone" development.
239 This option specifies how missing objects are handled.
240
241 The form --missing=error requests that pack-objects stop with an
242 error if a missing object is encountered. This is the default
243 action.
244
245 The form --missing=allow-any will allow object traversal to
246 continue if a missing object is encountered. Missing objects will
247 silently be omitted from the results.
248
249 The form --missing=allow-promisor is like allow-any, but will only
250 allow object traversal to continue for EXPECTED promisor missing
251 objects. Unexpected missing object will raise an error.
252
253 --exclude-promisor-objects
254 Omit objects that are known to be in the promisor remote. (This
255 option has the purpose of operating only on locally created
256 objects, so that when we repack, we still maintain a distinction
257 between locally created objects [without .promisor] and objects
258 from the promisor remote [with .promisor].) This is used with
259 partial clone.
260
261 --keep-unreachable
262 Objects unreachable from the refs in packs named with --unpacked=
263 option are added to the resulting pack, in addition to the
264 reachable objects that are not in packs marked with *.keep files.
265 This implies --revs.
266
267 --pack-loose-unreachable
268 Pack unreachable loose objects (and their loose counterparts
269 removed). This implies --revs.
270
271 --unpack-unreachable
272 Keep unreachable objects in loose form. This implies --revs.
273
274 --delta-islands
275 Restrict delta matches based on "islands". See DELTA ISLANDS below.
276
278 When possible, pack-objects tries to reuse existing on-disk deltas to
279 avoid having to search for new ones on the fly. This is an important
280 optimization for serving fetches, because it means the server can avoid
281 inflating most objects at all and just send the bytes directly from
282 disk. This optimization can’t work when an object is stored as a delta
283 against a base which the receiver does not have (and which we are not
284 already sending). In that case the server "breaks" the delta and has to
285 find a new one, which has a high CPU cost. Therefore it’s important for
286 performance that the set of objects in on-disk delta relationships
287 match what a client would fetch.
288
289 In a normal repository, this tends to work automatically. The objects
290 are mostly reachable from the branches and tags, and that’s what
291 clients fetch. Any deltas we find on the server are likely to be
292 between objects the client has or will have.
293
294 But in some repository setups, you may have several related but
295 separate groups of ref tips, with clients tending to fetch those groups
296 independently. For example, imagine that you are hosting several
297 "forks" of a repository in a single shared object store, and letting
298 clients view them as separate repositories through GIT_NAMESPACE or
299 separate repos using the alternates mechanism. A naive repack may find
300 that the optimal delta for an object is against a base that is only
301 found in another fork. But when a client fetches, they will not have
302 the base object, and we’ll have to find a new delta on the fly.
303
304 A similar situation may exist if you have many refs outside of
305 refs/heads/ and refs/tags/ that point to related objects (e.g.,
306 refs/pull or refs/changes used by some hosting providers). By default,
307 clients fetch only heads and tags, and deltas against objects found
308 only in those other groups cannot be sent as-is.
309
310 Delta islands solve this problem by allowing you to group your refs
311 into distinct "islands". Pack-objects computes which objects are
312 reachable from which islands, and refuses to make a delta from an
313 object A against a base which is not present in all of A's islands.
314 This results in slightly larger packs (because we miss some delta
315 opportunities), but guarantees that a fetch of one island will not have
316 to recompute deltas on the fly due to crossing island boundaries.
317
318 When repacking with delta islands the delta window tends to get clogged
319 with candidates that are forbidden by the config. Repacking with a big
320 --window helps (and doesn’t take as long as it otherwise might because
321 we can reject some object pairs based on islands before doing any
322 computation on the content).
323
324 Islands are configured via the pack.island option, which can be
325 specified multiple times. Each value is a left-anchored regular
326 expressions matching refnames. For example:
327
328 [pack]
329 island = refs/heads/
330 island = refs/tags/
331
332
333 puts heads and tags into an island (whose name is the empty string; see
334 below for more on naming). Any refs which do not match those regular
335 expressions (e.g., refs/pull/123) is not in any island. Any object
336 which is reachable only from refs/pull/ (but not heads or tags) is
337 therefore not a candidate to be used as a base for refs/heads/.
338
339 Refs are grouped into islands based on their "names", and two regexes
340 that produce the same name are considered to be in the same island. The
341 names are computed from the regexes by concatenating any capture groups
342 from the regex, with a - dash in between. (And if there are no capture
343 groups, then the name is the empty string, as in the above example.)
344 This allows you to create arbitrary numbers of islands. Only up to 14
345 such capture groups are supported though.
346
347 For example, imagine you store the refs for each fork in
348 refs/virtual/ID, where ID is a numeric identifier. You might then
349 configure:
350
351 [pack]
352 island = refs/virtual/([0-9]+)/heads/
353 island = refs/virtual/([0-9]+)/tags/
354 island = refs/virtual/([0-9]+)/(pull)/
355
356
357 That puts the heads and tags for each fork in their own island (named
358 "1234" or similar), and the pull refs for each go into their own
359 "1234-pull".
360
361 Note that we pick a single island for each regex to go into, using
362 "last one wins" ordering (which allows repo-specific config to take
363 precedence over user-wide config, and so forth).
364
366 git-rev-list(1) git-repack(1) git-prune-packed(1)
367
369 Part of the git(1) suite
370
371
372
373Git 2.20.1 12/15/2018 GIT-PACK-OBJECTS(1)