Skip to content

Instantly share code, notes, and snippets.

@PHPirates
Last active March 7, 2023 14:28
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save PHPirates/e3dc8a70e3b71b2424bc8484de3c6c8c to your computer and use it in GitHub Desktop.
Save PHPirates/e3dc8a70e3b71b2424bc8484de3c6c8c to your computer and use it in GitHub Desktop.
How to use git bundles

Let machine M be the Main machine with the repo, and A the Auxiliary machine which wants to help out.

First time setup

  1. Machine M creates bundle with complete repo:
git bundle create repo.bundle HEAD master
  1. M sends repo.bundle to A.
  2. A clones repo from bundle:
git clone repo.bundle repo

A sends commits to M

  1. A checks with
git log --oneline master ^origin/master

that the correct commits are shown that are added. 2. A puts them in a bundle with

git bundle create commits.bundle master ^origin/master

Note that both master and origin/master could be replaced with commit refs.

  1. A sends bundle to M, M optionally checks bundle with git bundle verify commits.bundle
  2. M pulls commits to new branch other-master with
git pull commits.bundle master:other-master
  1. M could merge the branch.

Extra

M could add the bundle file as a remote, if the filename is always the same. M would git remote add bundle commits.bundle where bundle is the name of the remote. Beware that the path commits.bundle is relative to the repository top level! M can then git pull bundle.

References

git book

docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment