LinuxCommandLibrary

git-fast-import

Import data into Git repository efficiently

SYNOPSIS

git fast-import [options]

PARAMETERS

--force
    Override backup safety checks.

--stat
    Print statistics about imported objects.

--quiet
    Disable all non-fatal output.

--bare
    Treat working directory as bare repository.

--update-server-info
    Update auxiliary info files.

--export-marks=<file>
    Dump marks to file for resuming.

--import-marks=<file>
    Load marks from file to resume import.

--import-marks-if-exists=<file>
    Load marks only if file exists.

--relative-marks
    Use relative paths in marks files.

--no-relative-names
    Use absolute paths for trees.

--native-delays
    Process delays natively.

--strict
    Die on unknown commands.

--base-path=<path>
    Prepend path to all paths in stream.

--active-branches=<N>
    Maximum active branches in memory.

--big-file-threshold=<N>
    Threshold for big file packing (bytes).

--cat-blob-fd=<N>
    Output blobs to file descriptor N.

--depth=<N>
    Maximum delta depth.

--max-linear-depth=<N>
    Maximum delta chain length.

--export-pack-edges=<file>
    Dump pack edges to file.

--pack-edges
    Enable pack edge optimization.

--progress=<NUM>
    Enable progress reports every NUM objects.

--max-pack-size=<N>
    Maximum packfile size (bytes).

--big-pack-threshold=<N>
    Close packs larger than threshold.

--unpacked=<N>
    Keep N unpacked objects before packing.

--prune-refs
    Prune refs appearing in marks file.

--prune-refs-since=<time>
    Prune refs older than timestamp.

--rewrite-refs=<file>
    Rewrite refs per mapping file.

--remap-vrefs
    Remap pseudo refs to real refs.

DESCRIPTION

git-fast-import is a low-level plumbing command in Git that serves as a backend for efficiently importing large amounts of data into a Git repository. It reads a specialized fast-import stream format from standard input, consisting of commands like commit, blob, tag, checkpoint, and progress, along with their data payloads. This stream describes filesystem snapshots, commits, branches, tags, and notes.

The command constructs Git objects (blobs, trees, commits) and packs them efficiently using the native Git packfile format, bypassing slower alternatives like repeated git-hash-object, git-update-index, or git-mktree invocations. It supports features like mark files for resuming interrupted imports, branch creation/merging, reference rewriting, and progress reporting.

Designed for use by importer scripts (e.g., git-p4 for Perforce, git-svn for Subversion), it excels at bulk operations, handling millions of objects quickly while minimizing disk I/O. However, it requires precise adherence to the input protocol and is not intended for interactive or casual use.

CAVEATS

Requires exact fast-import stream format; errors cause abrupt exit.
High memory use for large histories; test on clones first.
Not for human-readable input or casual use.

MARKS FILES

Binary files tracking object IDs by mark numbers (<mark>) for resuming large imports across runs.
Allows incremental processing of massive repositories.

INPUT PROTOCOL

Stream uses LF-terminated commands: commit refs/heads/master, data 1234 followed by blob data, from ::mark::, etc.
Full spec in git-fast-import(1) manpage.

HISTORY

Developed by Shawn O. Pearce; introduced in Git 1.5.0 (2007) to enable fast bulk imports, replacing slower scripts. Evolved with Git core for better performance, delta handling, and resume support.

SEE ALSO

Copied to clipboard