git bundle
Administration
Pack commits and branches into a single file
The 'git bundle' command packs commits, branches and tags into one file. The file behaves like a remote: you can clone from it or fetch from it. It is how you move a repository without network access — on a USB stick, by email, into an isolated network. An incremental bundle (A..B) only carries newer commits and requires the older ones on the receiving side.
Synopsis
git bundle create <file> <git-rev-list-args>
git bundle verify <file>
git bundle list-heads <file>
git bundle unbundle <file>[ ] optional| or<arg> placeholder... repeatable--flag option
Options
Choosing the Right Option
Ways to move a repository
With and without network
| Command | Needs network |
|---|---|
git push / git clone <url> | Yes |
git bundle + copy the file | No |
Examples
Pack a branch
git bundle create shop.bundle mainEvery commit of main.
Clone from it
git clone shop.bundle shopA repository from the file.
Incremental
git bundle create update.bundle v1.0..mainOnly commits after v1.0.
Workflow Examples
1
git bundle create shop.bundle --allPack everything
2
git clone shop.bundle shopUnpack it on the other computer
Troubleshooting
error: Repository lacks these prerequisite commits
Cause: The bundle is incremental
Get a full bundle, or fetch the missing history first
Tips & Pitfalls
Best Practices
- ✓Run git bundle verify before sending a bundle.
Common Mistakes
- ✗Creating an incremental bundle for someone who lacks the older commits — verify tells you what is required.
FAQ
A:
It can be: git bundle create backup.bundle --all captures every branch and tag.