Quantcast
Channel: Whomwah.com » github
Viewing all articles
Browse latest Browse all 2

Setting up your own hosted private Git repository

$
0
0

Now I’m a fully paid up user of Github. It’s a wonderful service, site and community of developers. But for the account plan I can afford, I only get 5 private repositories. I’m happy to make my work public, but there are some bits of software I want to keep private right now and yet still have remote copies of, and this comes to more that 5. I still want to use Git, and maybe one day make them public on Github. Here’s my solution using my own hosting as a private Git repository and just using Git and SSH to do the job.

Before we start, I’m assuming that you have SSH access to your hosting, and you have Git installed both on your machine and on the host.

First create a folder on your remote machine to hold the repos

$ ssh myserver.com
$ mkdir git
$ exit

If you have the correct permission or sudo access you could do the same as me and create the dir at /opt/git. You’ll need to replace all other mentions of git with this new path if you go this route.

Navigate to the local git repos on your machine that you want to have a remote copy of. Running the command below will give you a bare copy of the repos in your tmp dir.

$ git clone --bare /path/to/myrepo/.git /tmp/myrepo.git

Now you need to get this copy onto your remote machine. There are various ways but the simplest is scp with the recursive flag set:

$ scp -r /tmp/myrepo.git myserver.com:git/myrepo.git

You have a couple of choices now. You can either just navigate in into your local git repos and add your remote git as a remote to your config like this:

$ git remote add myserver myserver.com:git/myrepo.git

or you can delete your old repos and check out the remote one. Make sure you backup the old one until you’re sure it works ok though.

$ git clone myserver.com:git/myrepo.git

You can now make changes and push them to your new remote repos when ever you want.

Hope this helps someone. It doesn’t solve everything, but is a simple way to have a private alternate copy of your Git repositories.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images