Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am thinking about starting a small project and I want to make its versioning with git.

Bitbucket seems a good option for me with their free plan. I want to use it as the main tool for working with git since they nice tools, like web-interface, Mac OS client, and so on. But in order to have higher protection from any accidental damages that can be caused by using third-party service I want also to install git on my NAS as a second back-up copy of the repository.

Now my question is, whether it is possible to create a repository on two different hosts and then keep them in sync? For example once per week I update the repository on my NAS to what is on the Butbucket. And in case something happens with Bitbucket, I still have full repository with full history of development on my local NAS storage.

And is there a way to import existing repository with full history to another git-service?

share|improve this question
    
i am using xpdev i wonder in your 2 system situation what the bennefit would be of rusing git in your case. just to be sure from every final build i make a usb backup. But basicly versioning is handled whitin xpdev so its not a real requirement. BTW if you own a fool proof NASS Raid1 or so you might consider running your own versioning systems there are some freeones too –  user613326 Apr 20 '13 at 17:05
    
But I want to have full versioning available in 2 places. If the third-party hosting dies, or the company , running it, just disappears, I want to have exactly the same experience still with all versioning history... –  BartoNaz Apr 21 '13 at 9:32
    
It means that I will have Bitbucket for comfort and git on NAS for 99.9% safety. –  BartoNaz Apr 21 '13 at 9:44
    
As for xp-dev its unlikely such company dies, they might change code hosting plans, prices, etc.. or merge with another company. But its a money milkcow for them. And they will also backup the valuable data. Its their business to stay in place. I use it with 3 developers, and our code exists at 5 different machines, where there is always a local source copy that gets synced at xp dev. XP dev is free if you have only a few projects. –  user613326 Apr 21 '13 at 17:12
    
Of course, it's unlikely. But still, you can never be 100% sure... –  BartoNaz Apr 21 '13 at 19:06
show 1 more comment

2 Answers

up vote 3 down vote accepted

Yes, that's exactly the beauty of DVCS such as git. You can use any number of different repos with the same state as the one on bitbucket or github.

Even you local copy (the repository on your computer) is usually a full clone of the remote repo.

The only thing you have to do to keep multiple repos in sync is pulling for one (usually called origin or upstream) and pushing to the backup copies.

share|improve this answer
    
Unfortunately all is not as shiny. See the cautionary take of KDE near-disaster. That is, make sure the backup does not delete things (branches, repositories, etc.) that were deleted on the backed up server. –  Jan Hudec Apr 19 '13 at 14:04
    
Thank you. That is valuable information. –  BartoNaz Apr 21 '13 at 9:32
    
I am still not sure if I understand it correctly. As far as I understand, pushing and pulling works with a certain version. But let's say I have a recent version of the code on my working machine. I have the git repository on the remote host (Bitbucket, Github, or anything else), that has full history of the code development up to the most recent version that I have on the working machine (if it was committed). And I have a repository on the NAS that is empty. Can I import the full history of the code from remote host to my NAS so that I have two identical repositories in two places, and how? –  BartoNaz Apr 21 '13 at 19:14
    
Clone the remote repository, then pull all updates (all branches) to it in regular intervals. A git clone contains the history, it's not like an svn checkout that has only the latest version. –  Wilbert Apr 22 '13 at 8:25
add comment

I think that mirroring is what I need. This article seems to describe exactly what I need. And this one as well.

I believe that it will make full copy with full history and even automatically commit new versions to the repositories on both hosts automatically.

Am I right?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.