bashadvanced

Git Bundle — Transfer Repos Offline

Create portable Git bundles for transferring repository data without network access.

bash
# Create a bundle of the entire repository
git bundle create repo.bundle --all

# Create a bundle of a single branch
git bundle create feature.bundle main

# Bundle with a range (incremental transfer)
git bundle create update.bundle v1.0..main

# Bundle last N commits only
git bundle create recent.bundle -10 main

# --- Transfer the .bundle file (USB, email, etc.) ---

# Verify a bundle is valid
git bundle verify repo.bundle

# Clone from a bundle
git clone repo.bundle my-project
cd my-project

# Fetch from a bundle into existing repo
git remote add usb /path/to/repo.bundle
git fetch usb main
git merge usb/main

# Incremental workflow:
# Day 1: Full bundle
git bundle create full.bundle --all
# Day 2: Only new commits since the tag
git tag last-bundle HEAD
# ... more work ...
git bundle create update.bundle last-bundle..HEAD

# List refs in a bundle
git bundle list-heads repo.bundle

# Unbundle (low-level alternative to clone)
git init new-project && cd new-project
git bundle unbundle ../repo.bundle

Use Cases

  • Transferring repos in air-gapped environments
  • Sharing code bundles via USB or secure transfer
  • Incremental offline synchronization between machines

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.