I need to transfer a complete repo to a new non-networked machine, preferable as a single file entity. The git bundle allows a git fetch
, git pull
First clone the repository, and include the --mirror
option.
git clone --mirror git@example.org:path/repo.git
This ensures all remote branched are also local branches ready for bundeling.
Then run
git bundle create repo.bundle --all
as described by the answer from Jakub Narębski
I would suggest you tar or zip the .git folder and simply unpack it in the new location and then do git reset --hard HEAD
. Everything required for all the branches is under .git and all you should need to do is adjust any remotes in the .git/config file or remove them.
tar cf myrepo.tgz .git
cp myrepo.tgz [USB_STICK]
... move to new machine ...
mkdir myrepo && cd myrepo
tar xpf [USB_STICK]/myrepo.tgz
git reset --hard HEAD
What is the right invocation to:
- Bundle all the branches in the current repo
Simple:
$ git bundle create repo.bundle --all
Here repo.bundle
is the name of bundle file you want to create. Note that --all
would not include remote-tracking branches... just like ordinary clone wouldn't either.
- Start up the new repo on the destination directory, i.e. get the root commit correctly installed
First, clone
is just init
+ fetch
(+ administrativia).
Second, you can use bundle file everywhere the repository URL can be used, so you can simply clone
from a bundle file:
$ git clone repo.bundle
This would create repo
as a git repository.