Skip to main content

You are here


Running my own Git server: GitList

For the longest time I've been wanting to streamline updates to my sites, ie. implement good software deployment technique and procedures. To be specific, start using Git for source code management, and Jenkins to deploy. No, I'm not drinking the whole Agile Kool-Aid. After all we're in 2015, and people who still continue to use FTP/SFTP to push out changes to their sites should really need to be practicing more long term sustainable procedures. Setting up a git server is really simple. See

Git workflow:
I prefer to only communicate with Git over ssh and not https. Since I don't use the default ssh port, the initial repository clone looks like this:

git clone ssh://[email protected]$GIT-SERVER:$SSH-PORT/home/git/$REPO

GitHub has become the defacto Git hosting provider. I think much of it's success, aside from the fact that Git is an amazing piece of software, is GitHub's polished web user interface. While Git ships with a daemon that provides a visual look at the repositories, it's definitely not pretty. I wanted to have a local GitHub like interface on my private git repos, so I decided to use GitList. GitList is fairly minimalistic. Requiring just PHP and mod_rewrite, it allows you to browse your repositories, view files under different revisions, commit history and diffs. Configuring GitList is really easy.

git clone
cd gitlist
chmod 777 cache
mv config.ini-example config.ini

Then update config.ini to point to the location where the Git repositories are stored in the server. On my server, they're located in /home/git.

repositories[] = '/home/git/' ;

Lastly, is just configuring the web server's virtual host. Since I use Apache mine looks like this.


        DocumentRoot /var/www/gitlist

        <Directory "/var/www/gitlist">
                AllowOverride All
                AuthType Basic
                AuthName "Git Repos"
                AuthUserFile /home/svn/.htpasswd
                Require valid-user

        SSLEngine on
        SSLCertificateFile /etc/httpd/certs/
        SSLCertificateKeyFile /etc/httpd/certs/
        SSLCACertificateFile /etc/httpd/certs/rubyninjaCA.crt

        ErrorLog logs/git_ssl_error_log
        CustomLog logs/git_ssl_request_log \
                "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"



Awesome Applications: 

Setting up a Git Server in CentOS 6.5

Install git.

[[email protected] ~]# yum install git

Add the developers group, all git users will be part of this group.

[[email protected] ~]# groupadd developers

Create the git user which will own all the repos.

[[email protected] ~]# useradd -s /sbin/nologin -g developers git
[[email protected] ~]# passwd git
Changing password for user git.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Update Permissions.

[[email protected] ~]# chmod 2770 /home/git/

Create an empty Git repo.

[[email protected] project1]# git init --bare --shared
Initialized empty shared Git repository in /home/git/project1/

Update file ownership and permissions.

[[email protected] project1]# chown -R git .
[[email protected] project1]# chmod 2770 /home/git/project1

Create a git user account.

[[email protected] git]# useradd -s /usr/bin/git-shell -g developers -d /home/git tony
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
[[email protected] git]# passwd tony
Changing password for user tony.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

At this point a regular user should be able to checkout the project1 repo from the Git server.

[email protected]:~$ mkdir ~/testing_shit/git_test
[email protected]:~$ cd ~/testing_shit/git_test && git init
[email protected]:~/testing_shit/git_test$ git remote add origin [email protected]:/home/git/project1

Interestingly enough, an initial first commit has to be made onto the repo in order for any regular user to be able to push the repo, ie master branch. I received the following error when trying do so.

[email protected]:~/testing_shit/git_test$ git push origin master
[email protected]'s password:
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:/home/git/project1'


[email protected]:~/testing_shit/git_test$ git commit -m 'Initial'
[master (root-commit) 7bb7337] Initial
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README.txt

[email protected]:~/testing_shit/git_test$ git push origin master
[email protected]'s password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 209 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:/home/git/project1
* [new branch] master -> master


Awesome Applications: 

Premium Drupal Themes by Adaptivethemes