Git Pull via Sneakernet

8 Jun 2012

Today I found myself needing to move some commits between two repositories. In general the best way to do this is by pulling changes from one into the other, but in this case the repositories did not have direct access to each other. Rather than copying an entire repository from one machine to another or mucking about with a pile of patches, we can save time by performing the sending and receiving sides of the network-enabled git fetch command by hand.

In the source repository, add the changes we want to move to a bundle that we can copy to a USB stick:

% git bundle create changes.bundle master..mybranch
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 313 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
% cp changes.bundle /media/usbstick

In the destination repository, ensure that we have the commits necessary to use the bundle and then tell git fetch to grab the changes from it:

% git bundle verify /media/usbstick/changes.bundle
The bundle contains 1 ref
7a1d2087f10e6db33e6b4a28e2c427b65238a62c refs/heads/mybranch
The bundle requires these 1 ref
/media/usbstick/changes.bundle is okay
% git fetch /media/usbstick/changes.bundle mybranch
Receiving objects: 100% (3/3), done.
Resolving deltas: 100% (2/2), completed with 2 local objects.
From /media/usbstick/changes.bundle
 * branch            mybranch   -> FETCH_HEAD
% git merge FETCH_HEAD
Updating 6f5fced..7a1d208
 README |    2 ++
 1 file changed, 2 insertions(+)

2 Responses to “Git Pull via Sneakernet”

  1. hspencer77 Says:

    Reblogged this on More Mind Spew-age from Harold Spencer Jr. and commented:
    Some good git stuff…

  2. Geovane Says:

    Thanks a lot for this tutorial I found it very hulefpl.I only used it as a last resort as I didn’t find anything else provided by svn (except dump and load, which is a ridiculous solution cause I should not have access to svn machine to be able to create multiple commits with different revisions).anyway When I followed the steps you providedafter I entered the command:git rebase git-svnI got errors like the following one:CONFLICT (delete/modify): deleted in HEAD and modified in template and template instance creation implemented. Version template and template instance creation implemented of left in tree.And what that basically means is that there are some files that are not available on local git so whenever I got that I entered the following command till all was complete:git add -Agit rebase continueafter the last command completed successfully I completed as described in the tutorial.

Comments are closed.