So, git, I assume you're familiar with it -if not, take a look at this and this - . Those of you familiar with it may also be familiar with Github, the awesome git hosting service. And those of you who may have used github long enough, are thankful for being able to rest assured that your code will be on a reliable server and never, ever, get lost, even if you computer catches fire and then is stole by ghosts.
But, what happens when the unicorn strikes? Those very rare moments when something happens and github is down. With your code. Presumably when you most need to push or pull changes. That stuff happens, it's the law of nature, and not even a super rad site like github is exempt from some downtime, you know that. But what about your code?
I came up with some kind of solution for my projects, and no, it's not to store it in a usb every five seconds or having a magical RAID, it's just probability: for my really important projects, you can simply create backup repositories in other git hosting websites!
- Codaset lets you create free private repositories, yet in github, you pay for that. But it's like impossible to fork a project, at least is not as straightforward as in github
- Gitorious has different semantics for repositories: you create a project and in it, the repositories; so it's weird and its good or bad, depending on tastes
So, alright, you can create those repositories easily. But how do you manage three repositories from your project folder? Easy, two words:
Let's say you have a project called "HelloRadWorld", and created repositories in all three sites. Github probably would be your first, and, if you followed the instructions provided there, you'd have entered this command somewhere:
git remote add origin email@example.com:You/HelloRadWorld.git
See what you did there? You added a remote repository and named it "origin". Nice. You'll do the same for the other ones! Easy as pi! Let's see how it goes:
For your codaset repository, for example, you'll add the following:
git remote add codaset_backup firstname.lastname@example.org:You/HelloRadWorld.git
And something similar for the gitorious one. Presto, you have now three repositories to pull and push from with commands like git push/pull codaset_backup master. But pushing to all three of them could get tedious, so I got one extra trick for you: create an alias in your git config. I usually create a push alias called "all", so I can push to all the repositories in one command (like
git push all master
For pulls, I don't like the idea of downloading three of the same, so I don't configure the alias for that.
All of this configuration gets done in the file .git/config in your project folder, and it would look like this:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = email@example.com:you/HelloRadWorld.git fetch = +refs/heads/*:refs/remotes/origin/* [remote "gitorious_backup"] url = firstname.lastname@example.org:you/HelloRadWorld.git fetch = +refs/heads/*:refs/remotes/backup/* [remote "codaset_backup"] url = email@example.com:you/HelloRadWorld.git fetch = +refs/heads/*:refs/remotes/backup/* #an alias you can only push to: [remote "all"] url = firstname.lastname@example.org:you/HelloRadWorld.git url = email@example.com:you/HelloRadWorldgit url = firstname.lastname@example.org:you/HelloRadWorld.git
So there you go, git for paranoids, now, what are the odds of your computer catching on fire and all the servers in those three sites exploding. A hint: It's still not zero (isn't math lovely?)