基于git版本控制的Gerrit简易安装入门简介、使用和配置

简介

Gerrit 是一个基于 Web 的代码评审和项目管理的工具,面向基于 Git 版本控制系统的项目.

安装

banana% git clone git://android.git.kernel.org/tools/gwtexpui.git
banana% git clone git://android.git.kernel.org/tools/gerrit.git
banana% (cd gwtexpui && mvn install)
banana% cd gerrit && mvn clean package

banana% java -jar gerrit-war/target/gerrit-2.0.25-SNAPSHOT.war init -d /srv/gerrit
*** Gerrit Code Review v2.0.24.2-72-g4c37167
***

Initialize '/srv/gerrit' [y/n]? y

*** Git Repositories
***

Location of Git repositories   [git]:

*** SQL Database
***

Database server type           [H2/?]:

*** User Authentication
***

Authentication method          [OPENID/?]:

*** Email Delivery
***

SMTP server hostname           [localhost]:
SMTP server port               [(default)]:
SMTP encryption                [NONE/?]:
SMTP username                  :

*** SSH Daemon
***

Gerrit SSH listens on address  [*]:
Gerrit SSH listens on port     [29418]:

Gerrit Code Review is not shipped with Bouncy Castle Crypto v144
  If available, Gerrit can take advantage of features
  in the library, but will also function without it.
Download and install it now [y/n]? y
Downloading http://www.bouncycastle.org/download/bcprov-jdk16-144.jar ... OK
Checksum bcprov-jdk16-144.jar OK
Generating SSH host key ... rsa... dsa... done

*** HTTP Daemon
***

Behind reverse HTTP proxy (e.g. Apache mod_proxy) [y/n]? n
Use https:// (SSL)             [y/n]? n
Gerrit HTTP listens on address [*]:
Gerrit HTTP listens on port    [8080]: 

Initialized /srv/gerrit

创建项目

添加公钥后, 最好在$User.Home/.ssh中创建文件config, 里面输入以下内容:

Host $shortname
User $username
Port 29418
Hostname $gerrit.host
IdentityFile $path/to/private/key$

这个文件是可选的, 只是为了方便执行ssh命令.

banana% git checkout master
banana% git remote add gerritrhost ssh://gerrithost/py-yajl.git
banana% git push gerrithost master

修改和提交

banana% git checkout -b topic-branch 
banana% <work> 
banana% git commit 
banana% git push gerrithost HEAD:refs/for/master

审查通过后,提交自己的代码到远端的master上:

banana% git checkout master
banana% git merge topic-branch
banana% git push origin master
banana% git push gerrithost master

Gerrit可以将集中维护patch的功能和工作量,分散的各个提交者身上来完成;以及可以将你自己patch内容的更改可以实时地反应到gerrit web界面上。

我感觉这是它的最大的好处和优点。

03/14/2013