Host private #git repos using Nitrous.IO
Sometimes you are working on some project and you don't want to push the code to Github or similar, but you want to have it everywhere or just back it up so you don't rely on some of these providers. Nitrous.IO serves a simple way to this. Let's see how.
First, you need to create an account on Nitrous.IO, you can use your Github account for this purpose. Then you create a box, assign it a name, choose a region and set your preferred language/framework. Currently you can choose Ruby/Rails, Node.js, Python/Django or Go - the purpose of this post is language/framework agnostic, so your choice will not affect further steps.
Once your new box is created, next step would be to set your public key, so you can connect trustfully to this box. Grab your public key content, which might be located on ~/.ssh/id_rsa.pub
and add it as a new public key through the section Public Keys.
Let's connect to this box using ssh. Check your box information, where you'll see SSH URI with the follow format: ssh://action@euw1.actionbox.io:SOME_PORT
, this means you can connect to the box by running
$ ssh action@euw1.actionbox.io -pSOME_PORT
Once you are inside the box, let's create the repo for your local project, i.e.nitrapp
:
action@BOX_NAME:~$ mkdir git
action@BOX_NAME:~$ cd git
action@BOX_NAME:~$ mkdir -p nitrapp/nitrapp.git
action@BOX_NAME:~$ cd nitrapp/nitrapp.git
action@BOX_NAME:~$ git init --bare
Doing this, you just created a nice git repo available from everywhere outside this box. Let's add this remote to our local app and push your code there:
~/path/to/nitrapp$ git remote add nitrous ssh://action@euw1.actionbox.io:SOME_PART/home/action/git/nitrapp/nitrapp.git
~/path/to/nitrapp$ git push nitrous YOUR_BRANCH
And that's it, the git repository on your Nitrous.IO box already host your pushed code. You can get it from any other machine, as long as its public key is added correctly:
other_machine:~$ mkdir nitrapp
other_machine:~$ cd nitrapp
other_machine:~/nitrapp$ git pull nitrous master
other_machine:~/nitrapp$ git fetch nitrous # in case you prefer to fetch and rebase
There might be many other ways to host your repositories in a private way. I've been using it for a couple of months and it works fine and it's free.
Hope it is useful, feedback appreciated!
Written by Fernando Álvarez
Related protips
2 Responses
minor typo at the end of the the nitrous.io hyperlink :)
First off: "Sometimes you are working on some project and you don't want to push the code to Github or similar, but you want to have it everywhere or just back it up so you don't rely on some of these providers"
Err, as you're using it, isn't this just another such provider? ;)
Don't get me wrong, I kind of see the benefit (if you don't have your own, say, Vagrant scripts to easily set up identical development VMs), but if the intention is just as a form of repo hosting, I'd still much rather go through private Github or Bitbucket services..
Do they allow access to framework code? If not, I could see this as being a show stopper for me.. Far too many times I'm setting breakpoints deep in framework code to debug issues.