views:

240

answers:

2

I'm new to git so please feel free to RTFM me...

I have multiple development sites (none of which can communicate via a network with each other) and am working on a few projects (with a few people) at any one time.

What I would ideally have is at each site a centralized repository that can be pulled from but development would occur in our own (personal) repos. Then I would like to be able to sync across the centralized repos (via USB key for example).

I want a centralized repo at each location as (1) I'm new to git and do break my (personal) local repo by playing around and (2) some projects get put on hold so I want to be able to free up disk space by deleting them. This is the "backup" part of my question.

I was also hoping to be able to use 'git clone --bare' for my centralized repos (and the USB key repos to?) as we don't need the full checkout, just the git benefits.

However I can't seem to get a bare repo to work as repo I can push from. I've used 'git remote' to set up an remote origin (similar to http://toolmantim.com/thoughts/setting_up_a_new_remote_git_repository) but I can't get 'git push' to work - it seems I need a checked-out repo.

.

Does anyone else use this sort of repo/development structure or is there something fundamental about git usage that I'm missing?

.

A solution that I thought about that might not work - If I had a 'git clone --bare' at each site and then use a git repo on my removable media which has remotes set up for each site then I could ('pull') sync my USB key with each repo. But then can I update the site repo from my USB key? Could I push from USB?

+1  A: 

OK, let me just start off by saying that the whole premise of security by not being able to connect to the internet is completely misplaced. I shouldn't be judging without knowing all the facts, but considering the fact that you are asking this kind of basic question on StackOverflow means you are not a multi-national corporation developing a next generation of rail-guns and is under constant hacker attack.

Depriving developers of internet connection improves security by about 0.01% and slows them down as they can't research relevant stuff by about 1000%. You need to start off by advocating a better environment to whoever is in charge and have a hosted repository on a server somewhere. You can pay for a private github repository or roll out your own git repo on linux using gitorious or gitosis.

As for the actual problem. Instead of pushing from your bare repository, all you do is pull into it. You are on the right track with the last paragraph.

  1. Set up a bare repo at each site.
  2. Set up a bare repo on the USB stick.
  3. Developers push their changes to the site repo.
  4. Set up remotes on the stick to each of the sites.
  5. Pull to the USB stick from each of the site repos.

This is a good solution in theory but you would find that you will at some point get conflicts when syncing repos. In that case the developer needs to resolve those conflicts.

A better solution would be to not have the site repository. Because the whole repository is contained in a directory, you can make as many copies of it locally as you want. This will also address your "playing around" concern.

If the developers need to share code, they can just pull from each other. Then the USB stick comes in and they pull/push their changes. This way the people who create conflicts are the ones responsible for merging.

Let me again reiterate how much of a productivity burden this will be. It's hard enough to have a single shared repository with multiple people involved. With the time delay of manually synchronising the sites chances are if there is a bug, it won't be fixed today, but the day after.

Igor Zevaka
**To stop any further commentary** - I 100% agree with the thoughts around the false sense of security that the network policy gives. It is NOT my decision, in this respect I am a simple drone.
@ Igor - Also... Thanks for the thoughts about how this (painful) process could/should occur.
I think the most important point you made clear was **resolving conflicts when syncing**...it can't(?) work with bare repos - which makes our plan not fail. Our new approach is, whenever we want to update the USB drive, to "pull" from it, resolve conflicts and then "push" to it. I think we'll get around the backup issue by just copying folders locally. Not as clean as I'd have hoped, but still a workable solution. Thanks!
I actually realised that the steps I posted wouldn't work either for that precise reason. When you pull into a repository, there is a chance of a conflict occuring, so git wouldn't let you pull into a bare repo. That's actually the reason why you can't push from it as well - because to be able to push, you need to be able to pull.
Igor Zevaka
A: 

Another solution when it comes to backup from which you can pull from is:

git bundle

That way, you have:

  • only one file to copy on your USB key
  • you can pull directly from that bundle to update your local repo

Note: you are lucky to be able to use USB key. At our company, those USB port were blocked a long time ago;) Another "security" (big double quotes) measure...

VonC
We looked at bundles but it seemed to be not quite as easy as push/pull. Thanks for the suggestion - I've learned a new command. :)