LinuxCommandLibrary

git-fast-export

Export Git repository data

TLDR

Export the entire Git repository history to stdout

$ git fast-export --all
copy

Export the entire repository to a file
$ git fast-export --all > [path/to/file]
copy

Export a specific branch only
$ git fast-export [main]
copy

Export with progress statements every n objects (for showing progress during git fast-import)
$ git fast-export --progress [n] --all > [path/to/file]
copy

Export only a specific subdirectory's history
$ git fast-export --all -- [path/to/directory] > [path/to/file]
copy

SYNOPSIS

git fast-export [options] [[rev-list options]... [path...]]

PARAMETERS

--all
    Export all refs from refs/ namespace instead of command-line args

--branches[=file]
    Export only branches listed in file (or all if omitted)

--tags[=file]
    Export only tags listed in file (or all if omitted)

--refs[=file]
    Export refs listed in file (format: refname[:filename])

--unpack-v2
    Unpack version 2 objects (default unless --no-data)

--no-data
    Skip blob/file data; emit nodata markers

--marked
    Use mark tags for faster incremental imports

--fake-missing-tagger-names
    Invent tagger names for commits without them

--use-done-feature
    Emit done feature declaration

--bigfile-threshold=N
    Minimum size (bytes) for progress chunking (default 512 MiB)

--unroll=N
    Limit unrolled filemods per commit (default 1; 0=unlimited)

--depth=N
    Limit copy/rename chain depth (default 4096)

--format=fmt
    Blob format: raw or base85 (default raw)

--slot=N
    Index slot for checkout (0-1; default 0)

--export-all
    Export all objects including unreachable ones

--bare
    Treat repo as bare (no working tree)

DESCRIPTION

git-fast-export is a Git plumbing command that generates a fast-export formatted text stream from a Git repository. This format is optimized for high-performance importing via git-fast-import or compatible tools, preserving full history including branches, tags, merges, binaries, and trees.

It traverses specified revisions or all refs, outputting structured commands like commit, blob, tag, and filemodify. Key advantages include efficiency for large repos, support for incremental exports, and interoperability with other VCS via converters (e.g., hg-fast-export).

Typical uses: migrating repos, splitting monorepos, creating backups, or scripting conversions. Output is UTF-8 encoded and can be compressed or piped directly. Limitations include no support for grafts, shallow clones, or full submodule recursion by default.

Run without args to export current branch; use --all for everything. Pairs perfectly with git-fast-import for duplication or transformation.

CAVEATS

Ignores grafts, replace refs, and shallow history. Submodules exported as gitlinks only. No progress output by default; use --bigfile-threshold. Output assumes LF line endings.

COMMON USAGE

Export all: git fast-export --all | bzip2 > repo.fast-export.bz2
Incremental: git fast-export HEAD~10..HEAD --marked

OUTPUT NOTES

Stream starts with feature declarations (e.g., done, ls). Blobs use LFSP delimiters. Pipe to git fast-import for import.

HISTORY

Developed by Shawn O. Pearce in 2007 for Git 1.5.3.1 as companion to fast-import. Evolved with Git core; major enhancements in v1.6+ for marks, base85, and large-file handling. Widely used in VCS converters like git-p4, hg-fast-export.

SEE ALSO

git-fast-import(1), git-rev-list(1), git-archive(1), fast-export(5)

Copied to clipboard