fast-export and fast-import
git fast-export serializes a repository to a stream of commands; git fast-import reconstructs a repository from one. Together they form Git's data interchange protocol — used by importers (cvs2git, hg-fast-export, p4-fast-export) and by tools like git filter-repo internally.
Exporting
git fast-export --all > all.fi
git fast-export --all --signed-tags=strip --tag-of-filtered-object=drop > clean.fi
git fast-export --reference-excluded-parents main..feature > topic.fi
Importing
mkdir new-repo && cd new-repo && git init
cat ../all.fi | git fast-import
git checkout main
fast-import streams data, never holding the full set in memory — fast even for huge repos.
Use case: dehydrated archive
For ahead-of-time pack building (e.g., shipping a pre-built CDN clone), generate a deterministic packfile:
git rev-list --objects --all | \
git pack-objects --stdout --revs --delta-base-offset \
> offline.pack
Deterministic builds
fast-export with --no-data emits a metadata-only stream useful for scripts that build packs in CI:
git fast-export --all --no-data > metadata-only.fi
Anonymizing
For bug reports without leaking source:
git fast-export --all --anonymize > anon.fi
Authors, file names, and content are replaced with stable opaque tokens, preserving structure for reproduction.
Surgery via filter-repo
git filter-repo uses fast-export internally; that is why it is fast. See "filter-repo: rewriting history safely".
Common mistakes
Treating fast-export streams as portable archives — they are line-oriented and version-tied to a Git format; older Git may reject newer streams. Forgetting --signed-tags=strip when import would lose signatures. Mixing fast-export with custom tools that emit non-canonical paths; sort or re-export.
Performance
On a 10GB repo, fast-export streams at 200-500 MB/s on SSD. Pipelining export to import lets you reformat in one pass:
git fast-export --all | (cd /tmp/new && git init && git fast-import)
Related
See "filter-repo: rewriting history safely" and "Git archive and bundle for distribution".