Git review
作用
可以用来提交代码审核到Gerrit
安装
使用pip 安装 git-review 插件,执行
sudo -H pip install git-review
使用示例
可以参照 Hyperledger Cello 工程中给出的示范
注意事项
在从 gerrit中克隆代码的时候会需要ssh认证,如果你没有上传过ssh证书的,需要自己上传。证书的生成过程可以参考github中添加公钥证书的说明。
如果想要修正commit信息可以使用如下命令:
git commit --amend -s
在提交review的时候远程仓库会要求在提交者签名,这需要你在gerrit中设置GPG,设置过程可以参考github中添加GPG的说明。
需要提醒的是,有些系统的安装源比较落后,可以用gpg2来代替gpg。
另外,在使用-s命令去提交代码的时候,commit的标题、正文一定要写在 signed-off 的标志行上面,不要写在下面。而且gerrit对commit的标题长度和正文每行的长度都有限制,需要严格遵守,否则会提交失败:
常用命令
检测本地配置,-s 标志表示什么都不提交,仅仅执行repo setup
git review -s
强制提交,xxx代表分支名,强制推送到远程仓库
git push xxx -f
查看远程仓库
git remote -v
添加Upstream(上游工程)仓库,可以用于fork下来的工程
git remote add upstream xxx.git
更新fork工程与上游工程同步
git fetch upstream
git merge upstream/master
git push