Love Git but don’t want to pay GitHub to have a private repo? No problem. Here’s the solution. I was looking for a way to create a repo and serve it on my server via ssh. Git made it really simple and we can do in 3 steps (copied from the Reference 1):


1. Create a repo

# On the server side
mkdir ~/repos/
cd ~/repos/
GIT_DIR=project.git git init
cd project.git
git --bare update-server-info
cp hooks/post-update.sample hooks/post-update

2. Clone it on the client side via SSH

# On the client side. Check the [Reference 2]
git clone user@server:~/repos/project.git
mkdir project
cd project
git init
git remote add origin user@server:~/repos/project.git/

3. Code & Push

# On the client side
git add
git commit -m "Added readme."
git push origin master


  1. How to serve a Git repo via SSH:
  2. How to map SSH identity files to SSH servers & usernames: