A Git bundle can carry commits between repositories without a server. A full bundle can seed a new checkout. An incremental bundle can be smaller because it omits objects the recipient is expected to have. The critical check is to verify the update from the receiving repository, where missing prerequisite commits actually matter.

Prerequisites

Use Git 2.43 or a current release, Bash and standard command-line tools. Save this as bundle.sh and run it from a writable scratch directory. It makes fresh local repositories, uses synthetic commit authors and deletes only the generated exercise directory on exit.

set -eu
work=$(mktemp -d "$PWD/bundle.XXXXXXXX")
trap 'rm -rf -- "$work"' EXIT
cd "$work"
git init -q -b main source
git init -q -b main empty
commit() {
  git -C source -c user.name=Fixture -c [email protected] \
    -c commit.gpgsign=false commit -qm "$1"
}
printf 'one\n' > source/report.txt
git -C source add report.txt
commit base
git -C source bundle create "$work/base.bundle" main
git clone -q -b main "$work/base.bundle" receiver
printf 'two\n' > source/report.txt
git -C source add report.txt
commit update
git -C source bundle create "$work/update.bundle" main~1..main
if git -C empty bundle verify "$work/update.bundle" >verify.log 2>&1; then
  echo 'unexpected verification success' >&2
  exit 1
fi
grep -q 'prerequisite' verify.log
git -C receiver bundle verify "$work/update.bundle" >/dev/null 2>&1
git -C receiver fetch -q "$work/update.bundle" main
git -C receiver merge -q --ff-only FETCH_HEAD
test "$(git -C receiver rev-parse HEAD)" = "$(git -C source rev-parse HEAD)"
cat receiver/report.txt

Run LC_ALL=C GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_GLOBAL=/dev/null bash bundle.sh. Expected output:

two

Verify, fetch, then integrate

In the exercise the second bundle excludes main~1, the base commit, and advertises the updated main. Verification in the empty repository fails because that commit is absent. Verification in the receiver succeeds because it was seeded from the full bundle. Fetching the named ref makes the update available as FETCH_HEAD. The separate fast-forward-only merge ensures the checked-out branch advances without creating a merge commit. A final commit-ID comparison proves both test branches landed on the same commit.

On a real transfer, agree on the base commit ID instead of assuming that the previous commit on the sender is present on the receiver. If verification reports missing prerequisites, ask for a full bundle or an update based on a commit already present. If verification succeeds but the fast-forward fails, inspect both histories. Having the objects needed to apply a bundle does not mean the receiving branch is an ancestor of the advertised tip. Also check that the working tree is clean before updating a checkout.

Bundle verification is not proof of who sent the bundle. Apply your usual provenance and review checks separately. A bundle made from named refs also should not be mistaken for a backup of uncommitted files, hooks or repository configuration.

Reference: Git bundle documentation. More Git tutorials.