This tutorial assumes that you have openssh-server installed on your server so that you can ssh on to it. You should have a local repository on your development machine ready to go.

Set up your sever

1. Install git on your server

sudo apt-get install git-core

2. Create a git ssh user on your server (if you wish to use your own user, jump to step 4)

sudo adduser git

3. Create git ssh user home folder

sudo mkdir /home/git/.ssh
sudo chown -R git:git /home/git/.ssh

4. Add your ssh key

if you wish to use your ssh key, copy your public key {development_machine}:~/.ssh/ to {server}:/home/{GIT_SSH_USER}/.ssh/authorized_keys

5. Create an empty repository on server

mkdir {PATH_TO_REPO}/myrepo.git
cd {PATH_TO_REPO}/myrepo.git
git init –bare

Configure your development machine

cd {YOUR_LOCAL_REPO} git remote add {REPO_NAME} git@{SERVER_NAME_OR_IP}:{PATH_TO_REPO}/myrepo.git
git push {REPO_NAME} master

Add a default merge and remote:

git config branch.master.remote {repo_name} && git config branch.master.merge refs/heads/master