GIT-PACK-OBJECTS(1)
π NAME π
okay so bestie, you opened git-pack-objects(1) β the manual page for git-pack-objects β and the name is literally: Create a packed archive of objects. π«Άβ¨
β¨ SYNOPSIS β¨
the whole shape is this, no cap:
git pack-objects [-q | --progress | --all-progress] [--all-progress-implied]
[--no-reuse-delta] [--delta-base-offset] [--non-empty]
[--local] [--incremental] [--window=<n>] [--depth=<n>]
[--revs [--unpacked | --all]] [--keep-pack=<pack-name>]
[--cruft] [--cruft-expiration=<time>]
[--stdout [--filter=<filter-spec>] | <base-name>]
[--shallow] [--keep-true-parents] [--[no-]sparse]
[--name-hash-version=<n>] [--path-walk] < <object-list>
πΈ DESCRIPTION πΈ
okay so git-pack-objects reads a list of objects from standard input, and then writes either one or more packed archives with the specified base-name to disk, or a packed archive straight to the standard output. π
a packed archive is literally the efficient way to transfer a set of objects between two repositories, and itβs also an access-efficient archival format. in a packed archive, an object is either stored as a compressed whole or as a difference from some other object. that difference is often called a delta. π
the packed archive format (.pack) is designed to be self-contained so that it can be unpacked without any further information. therefore, each object that a delta depends upon must be present within the pack. π
a pack index file (.idx) is generated for fast, random access to the objects in the pack. placing both the index file (.idx) and the packed archive (.pack) in the pack/ subdirectory of $GIT_OBJECT_DIRECTORY (or any of the directories on $GIT_ALTERNATE_OBJECT_DIRECTORIES) enables Git to read from the pack archive. π«Ά
the git unpack-objects command can read the packed archive and expand the objects contained in the pack into "one-file one-object" format; this is typically done by the smart-pull commands when a pack is created on-the-fly for efficient network transport by their peers. πβ¨
π OPTIONS π
base-nameβ Write into pairs of files (.packand.idx), using<base-name>to determine the name of the created file. When this option is used, the two files in a pair are written in<base-name>-<SHA-1>.{pack,idx}files.<SHA-1>is a hash based on the pack content and is written to the standard output of the command. π--stdoutβ Write the pack contents (what would have been written to.packfile) out to the standard output. π--revsβ Read the revision arguments from the standard input, instead of individual object names. The revision arguments are processed the same way asgit rev-listwith the--objectsflag uses its commit arguments to build the list of objects it outputs. The objects on the resulting list are packed. Besides revisions,--notor--shallow <SHA-1>lines are also accepted. β--unpackedβ This implies--revs. When processing the list of revision arguments read from the standard input, limit the objects packed to those that are not already packed. π¦--allβ This implies--revs. In addition to the list of revision arguments read from the standard input, pretend as if all refs underrefs/are specified to be included. π--include-tagβ Include unasked-for annotated tags if the object they reference was included in the resulting packfile. This can be useful to send new tags to native Git clients. π--stdin-packs[=<mode>]β Read the basenames of packfiles (e.g.,pack-1234abcd.pack) from the standard input, instead of object names or revision arguments. The resulting pack contains all objects listed in the included packs (those not beginning with^), excluding any objects listed in the excluded packs (beginning with^). π§
When mode is "follow" packs may additionally be prefixed with !, indicating that they are excluded but not necessarily closed under reachability. In addition to objects in included packs, the resulting pack may include additional objects based on the following:
- If any packs are marked with
!, then objects reachable from such packs or included ones via objects outside of excluded-closed packs will be included. In this case, all^packs are treated as closed under reachability. π₯ - Otherwise (if there are no
!packs), objects within unlisted packs will be included if those objects are (1) reachable from the included packs, and (2) not found in any excluded packs. π
This mode is useful, for example, to resurrect once-unreachable objects found in cruft packs to generate packs which are closed under reachability up to the boundary set by the excluded packs. β¨
Incompatible with --revs, or options that imply --revs (such as --all), with the exception of --unpacked, which is compatible. π
--cruftβ Packs unreachable objects into a separate"cruft"pack, denoted by the existence of a.mtimesfile. Typically used bygit repack --cruft. Callers provide a list of pack names and indicate which packs will remain in the repository, along with which packs will be deleted (indicated by the-prefix). The contents of the cruft pack are all objects not contained in the surviving packs which have not exceeded the grace period (see--cruft-expirationbelow), or which have exceeded the grace period, but are reachable from an other object which hasnβt. π
When the input lists a pack containing all reachable objects (and lists all other packs as pending deletion), the corresponding cruft pack will contain all unreachable objects (with mtime newer than the --cruft-expiration) along with any unreachable objects whose mtime is older than the --cruft-expiration, but are reachable from an unreachable object whose mtime is newer than the --cruft-expiration). π«
Incompatible with --unpack-unreachable, --keep-unreachable, --pack-loose-unreachable, --stdin-packs, as well as any other options which imply --revs. π«
--cruft-expiration=<approxidate>β If specified, objects are eliminated from the cruft pack if they have an mtime older than<approxidate>. If unspecified (and given--cruft), then no objects are eliminated. π°οΈ--window=<n>,--depth=<n>β These two options affect how the objects contained in the pack are stored using delta compression. The objects are first internally sorted by type, size and optionally names and compared against the other objects within--windowto see if using delta compression saves space.--depthlimits the maximum delta depth; making it too deep affects the performance on the unpacker side, because delta data needs to be applied that many times to get to the necessary object. π
The default value for --window is 10 and --depth is 50. The maximum depth is 4095. π₯
--window-memory=<n>β This option provides an additional limit on top of--window; the window size will dynamically scale down so as to not take up more than<n>bytes in memory. This is useful in repositories with a mix of large and small objects to not run out of memory with a large window, but still be able to take advantage of the large window for the smaller objects. The size can be suffixed with"k","m", or"g".--window-memory=0makes memory usage unlimited. The default is taken from thepack.windowMemoryconfiguration variable. π§ π--max-pack-size=<n>β In unusual scenarios, you may not be able to create files larger than a certain size on your filesystem, and this option can be used to tell the command to split the output packfile into multiple independent packfiles, each not larger than the given size. The size can be suffixed with"k","m", or"g". The minimum size allowed is limited to1 MiB. The default is unlimited, unless the config variablepack.packSizeLimitis set. Note that this option may result in a larger and slower repository; see the discussion inpack.packSizeLimit. β οΈπ--honor-pack-keepβ This flag causes an object already in a local pack that has a.keepfile to be ignored, even if it would have otherwise been packed. πβ¨--keep-pack=<pack-name>β This flag causes an object already in the given pack to be ignored, even if it would have otherwise been packed.<pack-name>is the pack file name without leading directory (e.g.pack-123.pack). The option could be specified multiple times to keep multiple packs. π--incrementalβ This flag causes an object already in a pack to be ignored even if it would have otherwise been packed. π±--localβ This flag causes an object that is borrowed from an alternate object store to be ignored even if it would have otherwise been packed. π--non-emptyβ Only create a packed archive if it would contain at least one object. β--progressβ Progress status is reported on the standard error stream by default when it is attached to a terminal, unless-qis specified. This flag forces progress status even if the standard error stream is not directed to a terminal. π--all-progressβ When--stdoutis specified then progress report is displayed during the object count and compression phases but inhibited during the write-out phase. The reason is that in some cases the output stream is directly linked to another command which may wish to display progress status of its own as it processes incoming pack data. This flag is like--progressexcept that it forces progress report for the write-out phase as well even if--stdoutis used. π--all-progress-impliedβ This is used to imply--all-progresswhenever progress display is activated. Unlike--all-progressthis flag doesnβt actually force any progress display by itself. πͺ-qβ This flag makes the command not to report its progress on the standard error stream. π€«--no-reuse-deltaβ When creating a packed archive in a repository that has existing packs, the command reuses existing deltas. This sometimes results in a slightly suboptimal pack. This flag tells the command not to reuse existing deltas but compute them from scratch. π§Ό--no-reuse-objectβ This flag tells the command not to reuse existing object data at all, including non deltified object, forcing recompression of everything. This implies--no-reuse-delta. Useful only in the obscure case where wholesale enforcement of a different compression level on the packed data is desired. πβ¨--compression=<n>β sets the compression level for all the newly-compressed data in the pack you're making β¨. If you don't say anything, the level is picked first frompack.compression, then fromcore.compression, and if neither of those is set it defaults to-1, which is the zlib default, bestie. And real talk: if you want one uniform compression level slapped onto all the data no matter where it came from, add--no-reuse-objectπ .--sparse,--no-sparseβ flips the "sparse" algorithm on/off for deciding which objects go in the pack (only matters when you're rolling with--revs). This algorithm only walks trees that show up in paths that introduce new objects. Which is lowkey iconic for performance when you're computing a pack to send a tiny change π. But heads up: extra objects can sneak into the pack-file if the included commits contain certain types of direct renames π. If you don't pass this option, it defaults to the value ofpack.useSparse, which istrueunless otherwise specified.--thinβ makes a "thin" pack by leaving out the objects that the sender and receiver both already have, so less stuff goes over the network π¦. This option only makes sense together with--stdout.
β οΈ Note: a thin pack violates the packed archive format by omitting required objects, so Git literally can't use it unless you make it self-contained. Use git index-pack --fix-thin (see git-index-pack(1)) to restore that self-contained property, mmkay? π
--shallowβ optimizes a pack that's gonna be handed to a client with a shallow repository π«Ά. Team it up with--thinand you can get a smaller pack β at the cost of speed, ngl.--delta-base-offsetβ okay so a packed archive can express the base object of a delta either as a 20-byte object name or as an offset in the stream, but ancient versions of Git just don't understand the offset one π. By defaultgit pack-objectsonly uses the 20-byte-name format for better compatibility. This option lets the command use the offset format instead, for compactness. Depending on the average delta chain length, this typically shrinks the resulting packfile by 3-5 per-cent β¨.
π‘ Note: porcelain commands likegit gc(see git-gc(1)) andgit repack(see git-repack(1)) pass this option by default in modern Git when they put objects in your repository into pack files. So doesgit bundle(see git-bundle(1)) when it creates a bundle. iykyk π
--threads=<n>β how many threads to spawn while hunting for the best delta matches π₯. This requires thatpack-objectsbe compiled with pthreads β otherwise the option is ignored with a warning, sorry bestie. It's meant to cut down packing time on multiprocessor machines, but the required amount of memory for the delta search window gets multiplied by the number of threads π³. Specifying0makes Git auto-detect the number of CPU's and set the thread count accordingly.--index-version=<version>[,<offset>]β this one is intended to be used by the test suite only π§ͺ. It lets you force the version for the generated pack index, and force 64-bit index entries on objects located above the given offset.--keep-true-parentsβ with this, parents that are hidden by grafts get packed anyway π .--filter=<filter-spec>β omits certain objects (usually blobs) from the resulting packfile π. Peep git-rev-list(1) for valid<filter-spec>forms.--no-filterβ turns off any previous--filter=argument. bye felicia βοΈ--missing=<missing-action>β a debug option to help with future "partial clone" development π§. It specifies how missing objects are handled. The forms are:--missing=errorβ requests thatpack-objectsstop with an error if a missing object is encountered. If the repository is a partial clone, an attempt to fetch the missing objects will be made before declaring them missing. This is the default action π.--missing=allow-anyβ lets object traversal continue if a missing object is encountered. No fetch of a missing object will occur. Missing objects will silently be omitted from the results π€.--missing=allow-promisorβ likeallow-any, but it only allows object traversal to continue for EXPECTED promisor missing objects. No fetch of a missing object will occur. An unexpected missing object will raise an error π.
--exclude-promisor-objectsβ omits objects that are known to be in the promisor remote π. (This option exists so you're operating only on locally created objects, so that when we repack we still keep a distinction between locally created objects [without.promisor] and objects from the promisor remote [with.promisor].) It's used with partial clone.--keep-unreachableβ objects unreachable from the refs in packs named with the--unpacked=option get added to the resulting pack, on top of the reachable objects that aren't in packs marked with*.keepfiles π. This implies--revs.--pack-loose-unreachableβ packs unreachable loose objects (and their loose counterparts get removed) π¦. This implies--revs.--unpack-unreachableβ keeps unreachable objects in loose form. This implies--revs.--delta-islandsβ restricts delta matches based on "islands". See DELTA ISLANDS below ποΈ.--name-hash-version=<n>β so while doing delta compression, Git groups objects that might be similar based on heuristics using the path to that object π§ . Grouping by an exact path match is great for paths with many versions, but there are also benefits to finding delta pairs across different full paths. Git collects objects by type, then by a "name hash" of the path, then by size, hoping to group up objects that'll compress well together β¨.
The default name hash version is 1, which prioritizes hash locality by treating the final bytes of the path as providing the maximum magnitude to the hash function. This version excels at distinguishing short paths and finding renames across directories π. But β the hash function depends primarily on the final 16 bytes of the path. If your repo has a ton of paths that share those same final 16 bytes and differ only by parent directory, then this name-hash can lead to way too many collisions and cause poor results π. At the moment, this version is required when writing reachability bitmap files with --write-bitmap-index.
Name hash version 2 has similar locality features to version 1, except it considers each path component separately and overlays the hashes with a shift. It still prioritizes the final bytes of the path, but also "salts" the lower bits of the hash using the parent directory names π§. This method keeps some of the locality benefits of version 1 while breaking most of the collisions you'd get from a similarly-named file appearing in many different directories. At the moment, this version is not allowed when writing reachability bitmap files with --write-bitmap-index β it'll be automatically changed to version 1 π.
--path-walkβ performs compression by first organizing objects by path, then doing a second pass that compresses across paths as normal πΆβοΈ. This has the potential to improve delta compression, especially when filenames cause collisions in Git's default name-hash algorithm π₯.
When --use-bitmap-index is specified with --path-walk, a successful bitmap traversal is used for object enumeration, with path-walk staying as the fallback traversal for when the bitmap can't satisfy the request π¦. The --path-walk option supports the --filter=<spec> forms blob:none, blob:limit=<n>, tree:0, object:type=<type>, and sparse:<oid>. These supported filter types can be combined with the combine:<spec>+<spec> form π
.
π΄ DELTA ISLANDS π΄
okay so this is the part where it gets good β when it can, pack-objects tries to reuse existing on-disk deltas so it doesn't have to go hunting for new ones on the fly. and bestie, this is a major optimization for serving fetches, because it means the server can straight-up skip inflating most objects and just yeet the bytes directly from disk. iconic behavior, honestly.
but π«Ά this optimization can't work when an object is stored as a delta against a base that the receiver doesn't have (and that we're not already sending). in that case the server "breaks" the delta and has to find a new one, which costs a lot of CPU. so for performance it's genuinely important that the set of objects in on-disk delta relationships matches what a client would actually fetch. vibe check matters!!
in a normal repository this tends to just⦠work automatically ⨠the objects are mostly reachable from the branches and tags, and that's what clients fetch. any deltas we find on the server are likely to be between objects the client has or will have. slay.
but ngl, in some repository setups you may have several related but separate groups of ref tips, with clients tending to fetch those groups independently. for example, imagine you're hosting several "forks" of a repository in a single shared object store, and letting clients view them as separate repositories through GIT_NAMESPACE or separate repos using the alternates mechanism. a naive repack may find that the optimal delta for an object is against a base that is only found in another fork π but when a client fetches, they will not have the base object, and we'll have to find a new delta on the fly. pain.
a similar situation may exist if you have many refs outside of refs/heads/ and refs/tags/ that point to related objects (e.g., refs/pull or refs/changes used by some hosting providers). by default, clients fetch only heads and tags, and deltas against objects found only in those other groups cannot be sent as-is. π
Delta islands solve this problem by letting you group your refs into distinct "islands" ποΈ pack-objects computes which objects are reachable from which islands, and refuses to make a delta from an object A against a base which is not present in all of A's islands. the result? slightly larger packs (because we miss some delta opportunities), but it guarantees that a fetch of one island will not have to recompute deltas on the fly due to crossing island boundaries. worth it, fr fr.
when repacking with delta islands, the delta window tends to get clogged with candidates that are forbidden by the config π« repacking with a big --window helps (and doesn't take as long as it otherwise might because we can reject some object pairs based on islands before doing any computation on the content). efficiency queen π
Islands are configured via the pack.island option, which can be specified multiple times. each value is a left-anchored regular expressions matching refnames. for example:
[pack]
island = refs/heads/
island = refs/tags/
that puts heads and tags into an island (whose name is the empty string; see below for more on naming). any refs which do not match those regular expressions (e.g., refs/pull/123) is not in any island. and any object which is reachable only from refs/pull/ (but not heads or tags) is therefore not a candidate to be used as a base for refs/heads/. bye π
Refs are grouped into islands based on their "names", and two regexes that produce the same name are considered to be in the same island. the names are computed from the regexes by concatenating any capture groups from the regex, with a - dash in between. (and if there are no capture groups, then the name is the empty string, as in the above example.) this allows you to create arbitrary numbers of islands π only up to 14 such capture groups are supported though. fourteen. that's the cap. don't push it π
for example, imagine you store the refs for each fork in refs/virtual/ID, where ID is a numeric identifier. you might then configure:
[pack]
island = refs/virtual/([0-9]+)/heads/
island = refs/virtual/([0-9]+)/tags/
island = refs/virtual/([0-9]+)/(pull)/
that puts the heads and tags for each fork in their own island (named "1234" or similar), and the pull refs for each go into their own "1234-pull". so organized π
note that we pick a single island for each regex to go into, using "last one wins" ordering (which allows repo-specific config to take precedence over user-wide config, and so forth). last one wins, periodt.
βοΈ CONFIGURATION βοΈ
various configuration variables affect packing, see git-config(1) (search for "pack" and "delta"). go on, ctrl-f it, iykyk π
notably, delta compression is not used on objects larger than the core.bigFileThreshold configuration variable and on files with the attribute delta set to false. big files stay whole, no cap.
π SEE ALSO π
π GIT π
Part of the git(1) suite. one of us, one of us π«Ά
okay bestie that's the whole page β and just so you know exactly which flavor of the docs you're reading: this is Git 2.56.0, dated 2026-09-27, and it's the GIT-PACK-OBJECTS(1) page. go forth and pack those objects, you absolute icon πβ¨π
π¦ where this page comes from
- arch rolling: git 2.56.0-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms