Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between bundling and zipping a git repo?

Tags:

git

When I perform a

git bundle create ../`basename $PWD`.all.gitbundle --all

in a git repository the created bundle file has a size about 4.8MB. When I zip the entire repository folder the resulting file has 26,2MB.

Basically I look for a way to backup the entire repository without loosing any information. But given the archived file size differences I assume git bundle doesn't backup everything or is more efficient than a simple zip.

Could someone please shed light on this?

like image 557
Era Avatar asked Oct 03 '11 19:10

Era


People also ask

What is a git bundle?

Bundles are used for the "offline" transfer of Git objects without an active "server" sitting on the other side of the network connection. They can be used to create both incremental and full backups of a repository, and to relay the state of the references in one repository to another.

Can you push to a git bundle?

You cannot push directly to a bundle file. A bundle file is a compressed representation of a repository, and to modify it would involve unbundling, pushing, and bundling again. One way to do this is as you said, create a new bundle every time you want to make a backup.

Does git bundle include all branches?

Essentially, a bundle is an archive file that a user can use with the git clone command to create a local repository. The bundle contains your source code, as well as the change history for the commits and branches that you reference during the bundle creation step.

How do I zip a repository on GitHub?

Figure 10.12: Click Code and select Download Zip to create a compressed folder of a repo on your computer. Navigate to the location on your computer where you saved the folder. Its file name should end with . zip , which means you need to double-click to “unzip” or de-compress the folder.


3 Answers

The bundle command will package up everything that would normally be pushed over the wire with a git push

http://progit.org/2010/03/10/bundles.html

This means that the bundle will not have stale objects etc which will be part of your repository. Also, you should not count the actual files in the working directory of your repo, but only the .git with objects and other meta-data as it is these that the bundle will contain and not the files in their original form.

For backup you can look at using git clone --mirror option or just archiving the repo as you have done. A bundle is not a viable backup option for a repo as you will lose config, reflog, stale objects etc.

like image 117
manojlds Avatar answered Oct 16 '22 04:10

manojlds


I don't find git-bundle a good idea for maintaining a backup of your repository. Either create a bare repository and push onto it the refs you wish to track in your backup, or use good old tarballs. The difference between the two is that pushing allows you to back up only selective branches. For example, you might wish to ignore scratch branches in your backups. Zipping your repository will bluntly back up absolutely everything -- including your stash, untracked files, object files and any temporary editor files.

I usually just zip the whole thing. You might run git-clean -fdxn and then git-clean -fdx to carefully wipe out everything that's not stored in your repository. If you really insist on size efficiency when you perform the backup (and you shouldn't; just let Git worry about this), then you can garbage-collect before your backup, and maybe even prune your reflog. But you know, I wouldn't. Storage is cheap these days, and by doing so you merely lose on the backup's value.

like image 32
wilhelmtell Avatar answered Oct 16 '22 04:10

wilhelmtell


I think git uses zlib to compress.

zip isn't the greatest archiving format when it comes to size, though. zlib uses delta-compression to further reduce size, which is this (thanks Wikipedia):

Delta encoding is a way of storing or transmitting data in the form of differences between sequential data rather than complete files

That might account for your tiny filesize. I tried a file on the excreted git bundle, and it said that the bundle is just raw data.

like image 29
Blender Avatar answered Oct 16 '22 04:10

Blender