1GIT-REPACK(1) Git Manual GIT-REPACK(1)
2
3
4
6 git-repack - Pack unpacked objects in a repository
7
9 git repack [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-b] [-m] [--window=<n>] [--depth=<n>] [--threads=<n>] [--keep-pack=<pack-name>] [--write-midx]
10
12 This command is used to combine all objects that do not currently
13 reside in a "pack", into a pack. It can also be used to re-organize
14 existing packs into a single, more efficient pack.
15
16 A pack is a collection of objects, individually compressed, with delta
17 compression applied, stored in a single file, with an associated index
18 file.
19
20 Packs are used to reduce the load on mirror systems, backup engines,
21 disk storage, etc.
22
24 -a
25 Instead of incrementally packing the unpacked objects, pack
26 everything referenced into a single pack. Especially useful when
27 packing a repository that is used for private development. Use with
28 -d. This will clean up the objects that git prune leaves behind,
29 but git fsck --full --dangling shows as dangling.
30
31 Note that users fetching over dumb protocols will have to fetch the
32 whole new pack in order to get any contained object, no matter how
33 many other objects in that pack they already have locally.
34
35 Promisor packfiles are repacked separately: if there are packfiles
36 that have an associated ".promisor" file, these packfiles will be
37 repacked into another separate pack, and an empty ".promisor" file
38 corresponding to the new separate pack will be written.
39
40 -A
41 Same as -a, unless -d is used. Then any unreachable objects in a
42 previous pack become loose, unpacked objects, instead of being left
43 in the old pack. Unreachable objects are never intentionally added
44 to a pack, even when repacking. This option prevents unreachable
45 objects from being immediately deleted by way of being left in the
46 old pack and then removed. Instead, the loose unreachable objects
47 will be pruned according to normal expiry rules with the next git
48 gc invocation. See git-gc(1).
49
50 -d
51 After packing, if the newly created packs make some existing packs
52 redundant, remove the redundant packs. Also run git prune-packed to
53 remove redundant loose object files.
54
55 --cruft
56 Same as -a, unless -d is used. Then any unreachable objects are
57 packed into a separate cruft pack. Unreachable objects can be
58 pruned using the normal expiry rules with the next git gc
59 invocation (see git-gc(1)). Incompatible with -k.
60
61 --cruft-expiration=<approxidate>
62 Expire unreachable objects older than <approxidate> immediately
63 instead of waiting for the next git gc invocation. Only useful with
64 --cruft -d.
65
66 --max-cruft-size=<n>
67 Repack cruft objects into packs as large as <n> bytes before
68 creating new packs. As long as there are enough cruft packs smaller
69 than <n>, repacking will cause a new cruft pack to be created
70 containing objects from any combined cruft packs, along with any
71 new unreachable objects. Cruft packs larger than <n> will not be
72 modified. When the new cruft pack is larger than <n> bytes, it will
73 be split into multiple packs, all of which are guaranteed to be at
74 most <n> bytes in size. Only useful with --cruft -d.
75
76 --expire-to=<dir>
77 Write a cruft pack containing pruned objects (if any) to the
78 directory <dir>. This option is useful for keeping a copy of any
79 pruned objects in a separate directory as a backup. Only useful
80 with --cruft -d.
81
82 -l
83 Pass the --local option to git pack-objects. See git-pack-
84 objects(1).
85
86 -f
87 Pass the --no-reuse-delta option to git-pack-objects, see git-pack-
88 objects(1).
89
90 -F
91 Pass the --no-reuse-object option to git-pack-objects, see git-
92 pack-objects(1).
93
94 -q, --quiet
95 Show no progress over the standard error stream and pass the -q
96 option to git pack-objects. See git-pack-objects(1).
97
98 -n
99 Do not update the server information with git update-server-info.
100 This option skips updating local catalog files needed to publish
101 this repository (or a direct copy of it) over HTTP or FTP. See git-
102 update-server-info(1).
103
104 --window=<n>, --depth=<n>
105 These two options affect how the objects contained in the pack are
106 stored using delta compression. The objects are first internally
107 sorted by type, size and optionally names and compared against the
108 other objects within --window to see if using delta compression
109 saves space. --depth limits the maximum delta depth; making it too
110 deep affects the performance on the unpacker side, because delta
111 data needs to be applied that many times to get to the necessary
112 object.
113
114 The default value for --window is 10 and --depth is 50. The maximum
115 depth is 4095.
116
117 --threads=<n>
118 This option is passed through to git pack-objects.
119
120 --window-memory=<n>
121 This option provides an additional limit on top of --window; the
122 window size will dynamically scale down so as to not take up more
123 than <n> bytes in memory. This is useful in repositories with a mix
124 of large and small objects to not run out of memory with a large
125 window, but still be able to take advantage of the large window for
126 the smaller objects. The size can be suffixed with "k", "m", or
127 "g". --window-memory=0 makes memory usage unlimited. The default
128 is taken from the pack.windowMemory configuration variable. Note
129 that the actual memory usage will be the limit multiplied by the
130 number of threads used by git-pack-objects(1).
131
132 --max-pack-size=<n>
133 Maximum size of each output pack file. The size can be suffixed
134 with "k", "m", or "g". The minimum size allowed is limited to 1
135 MiB. If specified, multiple packfiles may be created, which also
136 prevents the creation of a bitmap index. The default is unlimited,
137 unless the config variable pack.packSizeLimit is set. Note that
138 this option may result in a larger and slower repository; see the
139 discussion in pack.packSizeLimit.
140
141 --filter=<filter-spec>
142 Remove objects matching the filter specification from the resulting
143 packfile and put them into a separate packfile. Note that objects
144 used in the working directory are not filtered out. So for the
145 split to fully work, it’s best to perform it in a bare repo and to
146 use the -a and -d options along with this option. Also
147 --no-write-bitmap-index (or the repack.writebitmaps config option
148 set to false) should be used otherwise writing bitmap index will
149 fail, as it supposes a single packfile containing all the objects.
150 See git-rev-list(1) for valid <filter-spec> forms.
151
152 --filter-to=<dir>
153 Write the pack containing filtered out objects to the directory
154 <dir>. Only useful with --filter. This can be used for putting the
155 pack on a separate object directory that is accessed through the
156 Git alternates mechanism. WARNING: If the packfile containing the
157 filtered out objects is not accessible, the repo can become corrupt
158 as it might not be possible to access the objects in that packfile.
159 See the objects and objects/info/alternates sections of
160 gitrepository-layout(5).
161
162 -b, --write-bitmap-index
163 Write a reachability bitmap index as part of the repack. This only
164 makes sense when used with -a, -A or -m, as the bitmaps must be
165 able to refer to all reachable objects. This option overrides the
166 setting of repack.writeBitmaps. This option has no effect if
167 multiple packfiles are created, unless writing a MIDX (in which
168 case a multi-pack bitmap is created).
169
170 --pack-kept-objects
171 Include objects in .keep files when repacking. Note that we still
172 do not delete .keep packs after pack-objects finishes. This means
173 that we may duplicate objects, but this makes the option safe to
174 use when there are concurrent pushes or fetches. This option is
175 generally only useful if you are writing bitmaps with -b or
176 repack.writeBitmaps, as it ensures that the bitmapped packfile has
177 the necessary objects.
178
179 --keep-pack=<pack-name>
180 Exclude the given pack from repacking. This is the equivalent of
181 having .keep file on the pack. <pack-name> is the pack file name
182 without leading directory (e.g. pack-123.pack). The option can be
183 specified multiple times to keep multiple packs.
184
185 --unpack-unreachable=<when>
186 When loosening unreachable objects, do not bother loosening any
187 objects older than <when>. This can be used to optimize out the
188 write of any objects that would be immediately pruned by a
189 follow-up git prune.
190
191 -k, --keep-unreachable
192 When used with -ad, any unreachable objects from existing packs
193 will be appended to the end of the packfile instead of being
194 removed. In addition, any unreachable loose objects will be packed
195 (and their loose counterparts removed).
196
197 -i, --delta-islands
198 Pass the --delta-islands option to git-pack-objects, see git-pack-
199 objects(1).
200
201 -g<factor>, --geometric=<factor>
202 Arrange resulting pack structure so that each successive pack
203 contains at least <factor> times the number of objects as the
204 next-largest pack.
205
206 git repack ensures this by determining a "cut" of packfiles that
207 need to be repacked into one in order to ensure a geometric
208 progression. It picks the smallest set of packfiles such that as
209 many of the larger packfiles (by count of objects contained in that
210 pack) may be left intact.
211
212 Unlike other repack modes, the set of objects to pack is determined
213 uniquely by the set of packs being "rolled-up"; in other words, the
214 packs determined to need to be combined in order to restore a
215 geometric progression.
216
217 Loose objects are implicitly included in this "roll-up", without
218 respect to their reachability. This is subject to change in the
219 future.
220
221 When writing a multi-pack bitmap, git repack selects the largest
222 resulting pack as the preferred pack for object selection by the
223 MIDX (see git-multi-pack-index(1)).
224
225 -m, --write-midx
226 Write a multi-pack index (see git-multi-pack-index(1)) containing
227 the non-redundant packs.
228
230 Various configuration variables affect packing, see git-config(1)
231 (search for "pack" and "delta").
232
233 By default, the command passes --delta-base-offset option to git
234 pack-objects; this typically results in slightly smaller packs, but the
235 generated packs are incompatible with versions of Git older than
236 version 1.4.4. If you need to share your repository with such ancient
237 Git versions, either directly or via the dumb http protocol, then you
238 need to set the configuration variable repack.UseDeltaBaseOffset to
239 "false" and repack. Access from old Git versions over the native
240 protocol is unaffected by this option as the conversion is performed on
241 the fly as needed in that case.
242
243 Delta compression is not used on objects larger than the
244 core.bigFileThreshold configuration variable and on files with the
245 attribute delta set to false.
246
248 git-pack-objects(1) git-prune-packed(1)
249
251 Part of the git(1) suite
252
253
254
255Git 2.43.0 11/20/2023 GIT-REPACK(1)