Version control is a critical part of software development. It is usually defined as the management of changes to a set of documents (or other information) belonging to a project.
Created by Linus Torvals (also the creator of Linux), Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
We’ve been using Github for some time now and, whilst we are really happy with the service, we feel that the pricing is a bit too aggressive. Let me explain!
Image courtesy of kyz.
Why?
We are, almost everyday, starting new projects and new repositories are being created. Whilst this is OK for a while, the total number of repositories is continually increasing and the monthly Github fee becomes unaffordable – we only have couple active projects during that month and it will be good to have an archive functionality that will let you pay only for the active projects.
Anyhow, I’ve decided to look into setting our own git server which, instinctively, I though will be a really hard task. It proved to be wrong! Just follow the steps below:
Conventions:
<SERVER> – your server name or IP address; this server will host a copy of your repositories
<CLIENT> – an unique identifier for each of your clients (we used this to organise the repositories better) – this is optional
<REPOSITORY> – the name of the repository you are going to create
Create a new git user
Whilst one can use any user accounts to store repositories, it is usually advisable to create a dedicated user. Log in as root on the server and create the user. Depending on your flavour of Unix you might need to issue a command like this:
adduser git
There is no need to issue a password for this account – we are going to use private keys.
cd /home/git
mkdir .ssh
cd .ssh
nano authorized_keys
Add all necessary public keys in there.
Create a repository
You are going to use the git user this time:
ssh git@<SERVER>
Create a folder for this client (this step is optional):
mkdir <CLIENT>
cd <CLIENT>
Create and initialize your repository:
mkdir <PROJECT>.git
cd <PROJECT>.git
git --bare init
Submit the initial content
On your local machine run:
mkdir <PROJECT>
cd <PROJECT>
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@<SERVER>:<CLIENT>/<PROJECT>.git
git push origin master
Open the champagne!
Your repository can be now be cloned using:
git clone git@<SERVER>:<CLIENT>/<PROJECT>.git

