fast-export Git Command Guide
The git fast-export command is used to export Git data in a format suitable for piping into git fast-import. It dumps revisions in a human-readable format that can be used as bundle replacement or for history rewrites.
git fast-export Syntax:
Section titled “git fast-export Syntax:”git fast-export [<options>]Options:
Section titled “Options:”| Option | Description |
|---|---|
| —progress= | Insert progress statements every n objects |
| —signed-tags=(action) | Handle signed tags (verbatim |
| —signed-commits=(action) | Handle signed commits |
| -M, -C | Perform move and copy detection |
| —export-marks= | Dump marks table to file |
| —import-marks= | Load marks from file |
| —mark-tags | Label tags with mark IDs |
| —fake-missing-tagger | Fake tagger for old repos |
| —use-done-feature | Use done stanza |
| —no-data | Refer to blobs by SHA-1 hash |
| —full-tree | Output deleteall + full file list |
| —anonymize | Anonymize repository contents |
| —tag-of-filtered-object=(action) | Handle filtered tags |
Parameters:
Section titled “Parameters:”| Parameter | Description |
|---|---|
| (none) | Operates on current repository |
| [ | Optional commit ranges to export |
git fast-export Command Samples:
Section titled “git fast-export Command Samples:”Basic export and import
Section titled “Basic export and import”git fast-export | git fast-importExports current repository and imports it back (creates a copy).
Export all branches with progress
Section titled “Export all branches with progress”git fast-export --progress=100 | git fast-importShows progress every 100 objects during the import process.
Incremental export with marks
Section titled “Incremental export with marks”git fast-export --export-marks=marks.txt HEAD | git fast-import --import-marks=marks.txtUses marks for incremental exports, allowing bidirectional syncing.
Export with move and copy detection
Section titled “Export with move and copy detection”git fast-export -M -C HEAD~10..HEAD | git fast-importEnables rename and copy detection in the exported stream.
Anonymize repository data
Section titled “Anonymize repository data”git fast-export --anonymize | git fast-importRemoves identifying information while preserving repository structure.
Export to bundle-like format
Section titled “Export to bundle-like format”git fast-export --no-data HEAD | gzip > repo.bundle.gzCreates a compressed bundle with blob references instead of content.
How do I export the entire repository?
Section titled “How do I export the entire repository?”To export the entire repository, run:
git fast-export HEAD | git fast-importHow can I handle incremental exports?
Section titled “How can I handle incremental exports?”To handle incremental exports, use marks files:
git fast-export --export-marks=marks.txt HEADgit fast-export --import-marks=marks.txt --export-marks=marks.txt NEW_COMMITHow do I anonymize repository data?
Section titled “How do I anonymize repository data?”To anonymize repository data, use the —anonymize option:
git fast-export --anonymize HEAD | git fast-importWhat is the output format of fast-export?
Section titled “What is the output format of fast-export?”git fast-export outputs a text stream format designed for git fast-import, containing commit, blob, and tree objects in a structured format suitable for editing and transformation.
How do I handle signed commits and tags?
Section titled “How do I handle signed commits and tags?”To handle signed commits and tags, use:
git fast-export --signed-tags=warn-strip --signed-commits=warn-strip HEADHow can I show progress during export/import?
Section titled “How can I show progress during export/import?”To show progress during export/import operations, use —progress option with fast-import (fast-export doesn’t have built-in progress):
git fast-export HEAD | git fast-import --progress=50Applications of the git fast-export command
Section titled “Applications of the git fast-export command”- Repository migration between Git hosts
- Historical data rewriting and filtering
- Creating anonymized repository copies for testing
- Implementing custom Git transformation pipelines
- Backup and archival of repository in text format