Self Host Git Server Based on Gitblit

OS: CentOS 7

Gitblit provides normal Git server and a easy-use Web panel

project official site:

Why Gitblit?

  • Free
  • Open Source (Apache License 2.0)
  • Unlimited
  • Based on JAVA 7 and Support JAVA API
  • Multiple Authentication
  • Use Groovy Scripts

What about shortcomings?

  • Based on JAVA, so not friendly to low-performance machine

    However, if you machine have at least one gigabyte memory, I think it should be fine.
  • Use Groovy Scripts instead of Shell as hooks of Git

Install JRE and JDK

Because Gitblit are written in JAVA 7, we need JDK 1.7

yum -y install java-1.7.0-openjdk*
if you have multiple JDK environment, make sure you could deal with the switch of versions of JDK!

Download Gitblit

  1. Go to the official site to find link like


  1. Make folder and Download

    mkdir -p /opt/gitblit    #make folder
    cd /opt
    wget #please replace the link with the latest one
    tar -zvxf gitblit*
    mv gitblit-1.8.0 gitblit
    cd gitblit

Configure Port

  1. open file ./data/

    make sure you have backup

    search these and configure as you want

    tips about port settings:
    you could use lsof -i :portNumber to find whether the port has been used
  1. open file ./

    change these as above



  1. install service

  2. start service

    service gitblit start


visit the web, and you could seegitblit_1.png

Default administrator username:admin

Default administrator password:admin


  1. HTTPS

    For default settings, the certificate comes from Linux kernel, if you have installed one.

    However, for most of time, I would like to use Nginx to proxy it.

  2. Hooks

    From my perspective, one of the most important things about Git is hooks. In Gitblit, you could write these scrips in Groovy, following built-in scripts at ./data/groovy

    For example, a post-Receive scripts for copying codes from master branch of a repository:

    1. copy ./data/groovy/localclone.groovy as ./data/groovy/autoCopy.groovy
    2. edit some lines in autoCopy.groovy
    def rootFolder = 'your original Dir'
    def cloneAllBranches = false
    def cloneBranch = 'refs/heads/master'

And enable the hook in Receive menu.


  1. More settings and Plugins

    See the official website.

    But I consider them helpless for individual use.

Last modification:March 5th, 2020 at 08:20 pm
Compared with money, your comment could inspire me more.