23

My project has a number of test PCs which are 100% off-net. We use a USB drive to transfer files to and from these PCs. Some development happens during the tests on those PCs. We transfer zips of the updated files, with the 'version info' coded in the name of the zip file.

My question is how best to use Git for managing the sneakernet transfer of files (or repos, or what?) between the project's office PCs and the test PCs. It's not the normal 'use case' that is often presented for laptop users being 'off-net' and developing in some corner cafe, and later getting back on net.

Has anyone got experience in such scenarios?


Also see the git bundle create <file> --all answer to transfer a complete repo

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Philip Oakley
  • 13,333
  • 9
  • 48
  • 71

4 Answers4

14

Using Git with unconnected computers is easy with git bundle.

See its man page.

Koraktor
  • 41,357
  • 10
  • 69
  • 99
6

You can also keep a clone of the repository on a USB drive. 'push' from the off-net PC to the USB drive, then 'push' from the USB drive to the central repository.

It might be better to have the USB drive repository with its own working directory (also on the USB drive). Then 'pull' to the USB drive from the off-net PC, and 'push' from the USB drive to the central repository. When that push happens, you can do merging, if necessary, on the USB drive.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Kent
  • 464
  • 4
  • 5
  • You don't really need to have a "central" repository if you're using git, but yes, pushing and pulling from repositories on USB drives would work. – Chris Frederick Jun 10 '11 at 00:55
  • My concern with having a full repository on the drive was the size and possibility of corruption, plus each developer has their own drive so sync could be 'lost'. I'm sure it will work for some workflows. – Philip Oakley Jun 10 '11 at 07:04
3

I found this tutorial even more helpful than the man page because it gives an example of how Git checks that the incoming bundle and the target repository share a common ancestor commit:

https://git-scm.com/book/en/v2/Git-Tools-Bundling

John Leonard
  • 909
  • 11
  • 18
chrisinmtown
  • 3,571
  • 3
  • 34
  • 43
  • The "I had to specify -b master because otherwise it couldn't find the HEAD reference for some reason," is because the cloning of the bundle has to guess which branch was the HEAD branch, as that information isn't encoded in the bundle. A backward compatible way of including the data hasn't been found yet. – Philip Oakley Dec 14 '13 at 12:09
3

Readers who get here are probably also interested in using-git-on-usb-stick-for-travelling-code which has a great set of similarities. It probably won't work for my environment where there are two of use doing the sneakernet use/edit movements (i.e two separate USB drives), but it is a possibility.

It all depends on how much you trust the transfer drive, and if the tools can work when you haven't got it plugged in....

Community
  • 1
  • 1
Philip Oakley
  • 13,333
  • 9
  • 48
  • 71