Create a backup or a bundle of your git repository
Materials and Methods
We will use thegit bundle
utility inside our local repository and also git merge
to deploy our bundled repo.git bundle
turns a repository into a single file that retains the versioning information of the entire project.Here are a list of options that are available:
git bundle create <name-of-the-bundle> <git-rev-list-args>
git bundle verify <file>
git bundle unbundle <file> [<refname>...]
Create a bundle
git bundle create ../myrepo.bundle master
Counting objects: 43, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (39/39), done.
Writing objects: 100% (43/43), 54.44 KiB | 0 bytes/s, done.
Total 43 (delta 8), reused 0 (delta 0)
myrepo.bundle
. When we created the file It was like we where just pushing our master branch to a remote, except it’s contained in a file instead of a remote repository.Verify the bundle
Before we move our bundle its a good idea to verify its content and check that the bundle file is valid and relevant to the current repository.While you are inside a repo run:
git bundle verify ../myrepo.bundle
The bundle contains this ref:
230b04bdd3367b2db73 refs/heads/master
The bundle records a complete history.
../myrepo.bundle is okay
Deploy the bundle
myrepo.bundle
file in /home/user
and you have created a folder newrepo
and initialized a git repository inside it. Here is a generic procedure:mkdir newrepo
cd newrepo
git init
git bundle unbundle ../myrepo.bundle
HEAD
of you repof7243ba54eb7de4b76a0 HEAD
myrepo.bubdle
file with the one that you initialized inside the newrepo
folder:git merge f7243b
Results and discussion
As you can see once you create the bundle file you can easily move it to another folder on the same or an other machine. Assume you want to transfer the history from a repository R1 on machine A to another repository R2 on machine B. For whatever reason, direct connection between A and B is not allowed, but we can move data from A to B via some mechanism (USB flash drive, email, etc..). This way we can update R2 with development made on the branch master in R1.References
- Ryan Hodson, Git Tips & Tricks : rypress.com
- Scott Chacon and Ben Straub, Pro Git : git-scm.com
Comments
Post a Comment