Chin Lee


Hosting Your Own Git Repositories

Published Feb 27, 2012

I was using Subversion as software versioning and revision control system with my previous company. Hosting repositories with Subversion is not easy, and it is a centralized system where you can’t have your own local commits; and mergings within branches to trunk always a nightmare for me.

I am happy to get to know about Git. Git is a free, open source and well developed source control management system developed by Linus Torvalds, initially for Linux kernel development.

Hosting with Git is easy, and it is a distributed version control system where you can have your codes committed to local or remotes. Git copy all of the data containing branches, tags and stored locally in client’s system in order to switch between branches in seconds. With Git, you can work offline, by committing your codes locally and push to the remotes whenever you have internet connections.


  • Linux or Unix based system
  • Git to be installed on both server and client
  • SSH access to the server

Git on Server

SSH to the server, create the repository and create a bare Git repository.

$ mkdir test.git
$ cd test.git
$ git --bare init

That is all for the server side.

Git on Client

Open up Terminal, create a working directory, create an empty Git repository.

$ mkdir test
$ cd test
$ git init

We have created an empty Git repository. We will now add a file and commit the changes.

$ touch README
$ git add README
$ git commit -a -m 'first commit'

We have committed the changes. We will now setup the remote server and push to the server.

$ git remote add origin [email protected]:test.git
$ git push origin master

That is all for the first commit. Each and every time you want to push the changes to remotes, you can just do git push


Code versioning makes our life easy! Try to start everything with git init today!