一、gerrit安装
准备环境:Java、git
adduser gerrit
su gerrit
mkdir repo_sites
java -jar gerrit-2.12.war init -d repo_sites
全部默认,安装完成后更改配置文件。
修改gerrit.config
[gerrit]
basePath = git
canonicalWebUrl = http://IP:8080/
[database]
type = h2
database = /home/gerrit/repo_sites/db/ReviewDB
[index]
type = LUCENE
[auth]
type = LDAP[ldap]
server = ldap://IP
username =xxxx@xxxx.com
accountBase = OU=xxxx,DC=xxxx,DC=com
accountFullName = cn
groupBase = OU=xxxx,DC=xxxx,DC=com[receive]
enableSignedPush = false
[sendemail]
smtpServer = server
smtpUser = xxxx@xxxx.com.cn
from = code Review <stjira@phicomm.com>
[container]
user = gerrit
javaHome = /usr/lib/jvm/java-7-openjdk-amd64/jre[sshd]
listenAddress = *:29418
[httpd]
listenUrl = http://*:8080/
[cache]
directory = cache
修改secure.config
[ldap]
password = xxxx
[auth]
registerEmailPrivateKey = jiFB1rbS9wH46vB7E+YZE5yS8o+7a/lxJr8=
[sendemail]
smtpPass = xxxx
../bin/gerrit.sh start启动服务
二、repo安装
下载repo脚本库(可添加服务器本地git仓库repo.git)
在gerrit中创建名为manifest的project,向manifest中添加如下格式的default.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="origin"
fetch="ssh://IP:29418"
review="http://IP:8081"/>
<default revision="master"
remote="origin"
sync-j="4" />
<project name="project"
path="project" />
</manifest>
在客户端:将repo脚本库中的repo文件添加到/bin 中并修改其权限 chmod 777 repo
修改以下两处
#REPO_URL='https://gerrit.googlesource.com/git-repo'
REPO_URL="ssh://IP:29418/repo.git"
#REPO_REV='stable'
REPO_REV='master'
用repo方式下载、提交代码
下载:repo init -u ssh://IP:29418/manifest.git -b master
repo sync
repo start branchname --all
上传:进入代码目录,编辑代码
git add .(filename)
git commit #如果首次commit代码,会自动生成commit模板,会直接退出,这时,直接再commit一次就好
repo upload #repo 会自动搜索这套代码下所有未提交的代码并提交,上传代码时可以指定review人 格式为 repo upload --re=ming.xing
git push origin 远程分支:本地分支 #也可提交代码
repo相关介绍: http://www.360doc.com/content/14/0220/17/97538_354256755.shtml
gerrit相关介绍:http://blog.csdn.net/benkaoya/article/details/8680886
gerrit管理员命令查看帮助:ssh -p 29418 IP gerrit --help
命令行创建git仓库: ssh -p 29418 username@IP gerrit create-project mani -p All-Projects --empty-commit