Setting Git server on VPS

Previously, I had set up a git server on my laptop. My friends would access it using my always changing IP. Furthermore, my laptop has to remain online.

Setting up a vps as git server
First create a git user
$sudo adduser git

A user and a group git would be created

Create accounts for your collaborators too using the same commands
$ sudo adduser rambo
$ sudo adduser rofler

Creating a group for the peeps working on a specific project.
$ sudo addgroup kuyon

Adding the collaborators to the group kuyon
$ sudo adduser rambo kuyon
$ sudo adduser rofler kuyon

Create a directory for each project you are working. By convention, it should end with .git

$ sudo mkdir /git/meraproject.git
$ sudo git init --bare
$ sudo chown -r git:kuyon /git/meraproject.git
$ sudo chmod -r 070 /git/meraproject.git

The above permission means that no one except those found in the group kuyon would have read, write and execute permission.

Now your collaborators can push an existing git project using this command

$ git remote add origin rambo@example.com:/git/meraproject.git
$ git push -u origin master

Roffler can clone the repository using rofler@example.com:/git/meraproject.git

Then the normal git workflow continues and life continues…

Note: the commands were written on Ubuntu Server 13.04

Leave a Reply

Your email address will not be published. Required fields are marked *