LinuxCommandLibrary

git-pack-objects

Create a packed archive of Git objects

SYNOPSIS

git pack-objects [<options>] <directory>
git pack-objects [<options>] --stdout

PARAMETERS

--all
    Pack all objects found in the repository that are not yet packed.

--honor-prerequisites
    Consult the pack.honorPrerequisites configuration setting to determine if pack prerequisites should be considered, meaning objects that the remote side is known to have already.

--non-empty
    Only create a pack file if it contains at least one object.

--local
    Only pack objects that are considered local (not already packed in other packs present in the repository).

--stdout
    Write the pack file to standard output instead of creating a file in the specified directory. When used, the index file is typically not written unless --indexed-objects is also used.

--indexed-objects
    When reading from stdin, assume objects are already indexed in an existing pack file. Primarily for internal optimization during certain Git operations.

--delta-base-offset
    Store delta base addresses as offsets from the delta itself instead of object ID references. This is the default format for new packs.

--threads=<n>
    Specify the number of threads to use for delta compression. A value of 0 uses the number of available CPU cores.

--shallow
    Only pack objects that are part of a shallow clone, omitting history beyond the shallow boundary.

--unpacked
    Only pack objects that are not already present in an existing pack file. Similar to --local.

--window=<n>
    The maximum number of objects to look at as candidates for delta compression. A larger window finds better deltas but uses more memory and CPU. Defaults to 10.

--depth=<n>
    The maximum depth of the delta chain. A deeper chain can save more space but requires more computation to decompress. Defaults to 50.

--no-reuse-delta
    Do not attempt to reuse existing delta chains from other packs during the packing process, even if they would be efficient.

--no-reuse-object
    Do not attempt to reuse existing objects from other packs when creating a new pack. This means the object will be duplicated if it's already in another pack.

--max-pack-size=<n>
    Break the pack file into multiple pack files if the total size of objects exceeds this limit (in bytes).

--progress
    Show progress indications on standard error while packing.

--no-progress
    Do not show progress indications.

--incremental
    Optimize for incremental packing, meaning fewer objects are processed to find deltas, assuming the input objects are mostly new and the repository already has existing packs.

--thin
    Create a 'thin pack', which omits objects that are expected to be present on the receiving side of a fetch or push operation. This reduces network transfer size.

--with-ref-info
    Include reference information in the pack header, which can be used by the receiving side for transfer optimization.

DESCRIPTION

git-pack-objects is an internal Git plumbing command responsible for creating highly efficient pack files and their corresponding index files. It reads a list of object IDs from standard input, resolves them, and then writes a single pack file and its associated index file. Pack files optimize storage by delta-compressing objects that are similar, significantly reducing disk space and improving transfer efficiency, especially for large repositories. This command is typically invoked by other Git commands that need to bundle objects for storage or transmission, such as git gc (garbage collection) or git upload-pack (server-side sending of objects during a fetch or clone operation). It is not generally intended for direct user interaction.

CAVEATS

This is a low-level "plumbing" command and is generally not intended for direct use by end-users. It is primarily invoked by other Git commands like git gc, git upload-pack, and git receive-pack. Misuse can lead to repository corruption or unexpected behavior. It expects object IDs to be fed into its standard input.

PLUMBING COMMAND

git-pack-objects is categorized as a "plumbing" command within Git. This means it's a low-level command designed to be used by other Git commands or automated scripts, rather than directly by typical end-users. It operates directly on Git's core data structures, such as objects and pack files, providing fundamental building blocks for higher-level operations.

PACK FILES

Pack files (typically ending with .pack) are Git's highly optimized storage format for objects. They consolidate multiple Git objects (like commits, trees, blobs, and tags) into a single file, predominantly using delta compression. Delta compression stores only the differences between similar objects, saving significant disk space and improving transfer efficiency. Each pack file is accompanied by an index file (.idx) that allows Git to quickly locate and retrieve any object within the pack.

HISTORY

git-pack-objects is a foundational component of Git's object storage model, existing since the early stages of Git's development (circa 2005-2006). Its core function of delta-compression and efficient packing has been crucial for Git's performance and distributed nature. It has undergone continuous development, with enhancements like multithreading, improved delta algorithms, and specialized packing modes (e.g., thin packs, incremental packs) being added over time to optimize for various repository sizes and network conditions.

SEE ALSO

Copied to clipboard