LinuxCommandLibrary

git-index-pack

Create a pack index file from a pack

SYNOPSIS

git index-pack [-k] [-v] [-o <index-file>] [--stdin] [--fix-thin] [--keep-optional] [--threads=<n>] [--verify] [--verify-objects] <pack-file>

PARAMETERS

-k
    Keep the pack file after indexing.

-v
    Enable verbose output during processing.

-o <index-file>
    Write index to specified <index-file> instead of default.

--stdin
    Read pack data from stdin rather than a file.

--fix-thin
    Add missing objects to thin packs from git pack-objects --thin.

--keep-optional
    Retain optional packs (for git pack-objects compatibility).

--threads=<n>
    Use <n> threads for faster index computation (default: 1).

--verify
    Verify generated index matches pack checksums.

--verify-objects
    Additionally verify all object checksums in the pack.

DESCRIPTION

git index-pack is a low-level plumbing command in Git that generates an index file (.idx) for a pack file (.pack). Pack files are compressed bundles of Git objects (blobs, trees, commits) used for efficient storage and transfer. The index provides fast lookup by object ID, offsets, and checksums, enabling quick access without unpacking.

Invoked automatically during git fetch, git clone, or git repack when handling remote or local packs. It processes pack data, resolves deltas, verifies integrity if requested, and supports thin packs (missing base objects). Multi-threading accelerates large pack indexing.

Primarily for scripts or Git internals; end users rarely invoke directly. Ensures repository consistency by validating SHA-1 hashes and pack structure.

CAVEATS

Plumbing command; not for interactive use. Requires write access to .git/objects/pack/. Fails on corrupt packs.

COMMON USAGE

Automatically called by Git during fetches. Manual: git index-pack .git/objects/pack/pack-abc.idx to reindex a pack.
Avoid direct use unless scripting Git internals.

HISTORY

Introduced in Git 1.4.2 (April 2007) to improve packfile handling efficiency, evolving with Git's delta compression and multi-threaded features in later versions like 2.0+.

SEE ALSO

Copied to clipboard