Oct. 5, 2008, 12:57 a.m.

Using Git Bundle When Your Central Repo Fails

I have an application of mine I did a bunch of work on tonight and wanted to deploy that work on the VPS that runs it.

Unfortunately, after pushing my changes to github, I found that I couldn't pull from this box. I don't know whether it was because of some port filtering stuff or a broken machine at github. It was a great opportunity to try out git bundle, though.

What is Git Bundle?

A bundle is a way to put a bunch of changesets into a file so you can exchange them out of band while maintaining object IDs (as opposed to a git format-patch/git am sequence).

How Do I Make One?

In my case, my remote tree had change 23b730, but I had several changes out of that and my normal means of moving code around (git:// from github) wasn't working. The bundle creation to package up all changes and blobs after 23b730 was pretty straight-forward:

% git bundle create /tmp/cmd.git 23b730..

That created the file /tmp/cmd.git.

Neat, Now How Do I Use It?

First, get that file where you need it. Email it, put it on a web server, scp it, whatever. Once there, you unbundle it into the target repo using the git bundle unbundle command. Here's my example:

% git bundle unbundle /tmp/cmd.git 
0b6bf526dc3c9544288444dbe7eb58c7d091038e HEAD

Note that 0b6bf52 is my dev head I'm wanting to deploy. This does not change any of your branches, it only shoves the object into the git filesystem. You can either reset your branch or merge it at this point. I chose a merge (which, as I expected, was a fast-forward):

% git merge 0b6bf52

Now you're done. Code is deployed and all's well.

blog comments powered by Disqus