How do I settup Git as a Git server like GitHub, so I can create private repositories, etc.?

I have installed LAMP. It's up and running smoothly and also Git with GITWEB works perfect. The only thing I don't get is how to use it as a server for my private repositories.

How can I do this? It there a good tutorial, because I haven't found anything really usable yet..


There's a book about called Pro Git, freely available and downloadable over the Internet. That book has the "Git on the Server" chapter, that explains in thorough details how to install Git in different configurations according to your needs.

| improve this answer | |
  • You should answer with an explanation, not with a reference – GuySoft Jun 24 '13 at 14:51
  • 1
    @GuySoft please, read the question thoroughly next time. OP asked for a tutorial, and I gave him one. – lenik Jun 25 '13 at 2:06
  • Ok, my bad. I guess at least you can link to that chapter. – GuySoft Jun 25 '13 at 7:54

Setting up a Git server (multi-user)

Handle Git user

Install gitolite or gitosis

Allow web access

Install gitweb


I prefer gitolite.

Setting up a Git server (single-user)

Git user

Create Git user

  1. Create Git user
    • sudo useradd -m git
    • sudo passwd git
  2. Add your key to your Git user (from another machine)
    • ssh-copy-id -i /path/to/id.pub git@host

Lock down Git user

vim /etc/ssh/sshd_config

Match User git
#ChrootDirectory /home/git/  #Look into this and see if you want it enabled.
AllowTCPForwarding no
X11Forwarding no
PasswordAuthentication no

sudo service ssh restart

Create your Git repository

sudo su - git

mkdir /home/git/reponame.git

cd /home/git/reponame.git

git init --bare

Look into using Git hooks to push code to another location when updating (post-update).

Push to your new repository

git push git@host:reponame.git master

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.