fast-import Git Command Guide
The git fast-import command is used to import Git data streams from stdin and write packfiles directly into the current repository. It is the backend for fast Git data importers that reads a mixed command/data stream.
git fast-import Syntax:
Section titled “git fast-import Syntax:”<frontend> | git fast-import [<options>]Options:
Section titled “Options:”| Option | Description |
|---|---|
| —force | Force update modified branches |
| —quiet | Disable statistics output |
| —stats | Show basic statistics (default) |
| —allow-unsafe-features | Enable potentially dangerous features |
| —cat-blob-fd= | Write cat-blob responses to file descriptor |
| —date-format= | Specify date format for import |
| —done | Require done command at end of stream |
| —export-marks= | Export marks table to file |
| —import-marks= | Import marks from file |
| —import-marks-if-exists= | Import marks if file exists |
| —[no-]relative-marks | Use relative paths for marks files |
| —active-branches= | Max active branches (default 5) |
| —big-file-threshold= | Max size for delta creation |
| —depth= | Max delta depth (default 50) |
Parameters:
Section titled “Parameters:”| Parameter | Description |
|---|---|
| (stdin) | Mixed command/data stream from frontend |
git fast-import Command Samples:
Section titled “git fast-import Command Samples:”Import from fast-export
Section titled “Import from fast-export”git fast-export HEAD | git fast-importImport current repository (creates a copy).
Incremental import with marks
Section titled “Incremental import with marks”git fast-export --import-marks=marks.txt --export-marks=marks.txt HEAD | git fast-import --import-marks=marks.txt --export-marks=marks.txtUse marks for incremental bidirectional syncing.
Import with statistics
Section titled “Import with statistics”some-frontend | git fast-import --statsImport with statistics display at completion.
Quiet import with cat-blob responses
Section titled “Quiet import with cat-blob responses”frontend | git fast-import --quiet --cat-blob-fd=3 3>&-Import quietly with blob queries sent to fd 3.
Force update existing branches
Section titled “Force update existing branches”import-stream | git fast-import --forceForce import even if it would lose commits.
Generate reports on completion
Section titled “Generate reports on completion”git fast-import --stats < import.streamShow detailed statistics after import completion.
How do I import using fast-export?
Section titled “How do I import using fast-export?”To import using fast-export, run:
git fast-export HEAD | git fast-importHow can I handle incremental imports?
Section titled “How can I handle incremental imports?”To handle incremental imports, use marks:
git fast-import --import-marks=marks.txt --export-marks=marks.txtHow do I see import statistics?
Section titled “How do I see import statistics?”To see import statistics, use the —stats option:
some-import-stream | git fast-import --statsHow can I force update branches?
Section titled “How can I force update branches?”To force update branches even if commits would be lost, use:
import-stream | git fast-import --forceHow do I handle blob queries?
Section titled “How do I handle blob queries?”To handle blob queries via file descriptor, use —cat-blob-fd:
frontend | git fast-import --cat-blob-fd=3How can I customize date formats?
Section titled “How can I customize date formats?”To customize date formats for import, use —date-format:
import-stream | git fast-import --date-format=rawApplications of the git fast-import command
Section titled “Applications of the git fast-import command”- Repository migration and conversion from other VCS
- Bulk import of historical data from foreign sources
- Repository reconstruction after corruption
- Automated CI/CD pipeline data import
- Creating mirror repositories from export dumps