8

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?

3
  • Every clone is a full copy of the repository. Make a clone of it and you have a backup -- that by the way can get updated extremely easy.
    – KingCrunch
    Oct 3, 2011 at 19:59
  • 1
    @KingCrunch: a clone isn't strictly speaking a "copy", since the branch structure is different. If you want a real copy, you want to add the --mirror flag to your clone. This will make the clone's branch structure mirror the original's exactly. Oct 3, 2011 at 20:10
  • 1
    Even a mirror is not an exact duplicate of your repository directory. You will still miss any custom settings you might have in your .git/config, you will still miss your stash any work you might have in progress, your stage area -- pretty much everything that's not recorded in the repository. Oct 3, 2011 at 21:04

3 Answers 3

1

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.

1

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.

1

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.

2
  • I think you're a bit misinformed. zlib compression uses delta encoding as part of how it works (that's basically how all compression works). Git itself stores the full, un-delta'd files as objects in its repo, and then relies on zlib to perform the delta compression (git is also smart enough to re-use deltas when doing incremental packing to speed up operations). Oct 3, 2011 at 20:09
  • Whoops. Then I guess it just uses zlib.
    – Blender
    Oct 3, 2011 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.