How can I daisy chain git repositories in a sneaker-net environment
I am working on developing some code for an embedded application. My embedded systems run linux/git and have a native compiler right on board, but they have no networking hardware or capability. I am able to happily mount a USB drive on these embedded systems.
I have my master (bare) git repository for the source code on my desktop PC, and do quite a bit of development there in a clone of the repository. The simple/basic git work flow is fine.
- Version control on a 2GB USB drive
- Using git to transfer data via usb stick between Windows and Linux
- Work with Subversion from USB Key
- How to run Git 1.6.x for Windows from a USB memory stick
- Git installation in USB Drive that works in both OSX and windows?
What I envision in my mind is creating a –bare clone of the repository on a USB thumb drive and then sneaker-netting that between my embedded systems.
I would like the git repository on board each embedded system to be a clone from the USB repository.
So the workflow I envision is this:
- Make some changes onbaord one of my embedded systems. Add and commit them to the local git clone.
- Mount the USB thumb drive to the embedded system and push the changes from the local repository to the thumb drive repository.
- Mount the USB thumb drive on my desktop PC and push those commits up to the master/bare repository
- Pull the changes into my desktop development tree.
And then I would like to do the reverse of this:
- Make changes to my desktop working git tree, add, commit, push them to the master repository.
- Mount the thumb drive on my desktop PC, pull/fetch the master changes into the git clone on the thumb drive.
- Mount the thumb drive on an embedded system, pull/fetch the changes into the local working tree on the embedded system …
The end goal is to be able to make development changes on my desktop PC or on any of my embedded systems (which do not have network ability) and keep everything in sync.
Is this possible? Is this possible without massive amounts of git voodoo?
I’ve sat down to work through this on a couple occasions and keep running into road blocks. I don’t think I want a –mirror’d repository on the thumb drive because I want to be able to push changes both directions through the thumb drive.
I could put the official master repository on the thumb drive and have all my working copies point to that I suppose, but that doesn’t give me warm fuzzy feelings about the security of my master copy if it gets buried.
I’m hoping for something ‘simple’ that I can understand and do myself!
One Solution collect form web for “How can I daisy chain git repositories in a sneaker-net environment”
[The assumption here is that we are just talking about regular git without any extras or addons]
Yes, indeed you can. There are a few things to remember here:
- The git repository is just the “.git” directory
- The git repository does not “know” where it is, so you can move or copy it without issue
- The git repository has a text file listing where its “remotes” are (ie where it can push/pull)
- There is no such thing as a “master” git repository: all repositories are equal
So, at its most primitive, you could just copy the .git directory about with “cp -a” and you’d be fine.
Of course, that’s not the best way…you probably want to push and pull and fancy stuff of that sort. So, what we can do is call a repository on your server the “remote” (ie. our “master”) repository for both the usb stick and for your desktop.
And call the usb stick repository the “remote” for the embedded systems.
The easiest way to do this is as follows (you’ve probably got the first two done already):
- Create your repository on your server
- git clone the server repository to a directory on your desktop
- Plug the usb stick into your desktop
- git clone the server repository to a directory on the usb stick
- Remove the usb stick and plug it into the embedded system
- git clone the repository from your usb stick to your embedded system (repeat last 2 steps for all embedded)
And that’s it. You can now push and pull from embedded to usb, and from usb to server and from server to desktop and usb.