1.注册
1.1 主页点击首页Become

1.2 点击页面最下面的Regitster New Account
1.3 填写注册表格
Add SSH Public Key这一步可以点击【4】看说明:
打开C:\Users\Administrator.ssh目录中的id_rsa.pub(SSH公钥)文件,复制其内容粘贴到【5】,点击【6】添加,点击continue完成注册。

2.clone项目
2.1 在.ssh目录下放入管理员提供的config文件(管理员提供)。

第一次使用如果没在.ssh中配置config文件的话,执行clone命令的时候会报下面的错误。

2.2 选择项目

2.3 选择clone with commit-msg hook【1】和SSH【2】两个选项,获取clone命令行【3】。
说明:
选择clone with commit-msg hook
可以再提交的时候自动加上change-id
选择SSH可以在提交的时候不用输入账号密码(注册的时候配置了SSH key)

2.4 打开git bash,输入上一步出现的git clone 命令:git clone ssh://test007@172.16.1.201:29418/handset-team/rs10-android-control && scp -p -P 29418 test007@172.16.1.201:hooks/commit-msg rs10-android-control/.git/hooks/
3.推送修改

3.1 背景知识
相比如git直接管理代码,gerrit多一个环节,就是图中那只鸟。
一般的contributor没有权限直接将代码push到git repo上,直接push会提示没有push权限。
You are not allowed to perform this operation. To push into this reference you need 'Push' rights.
所以需要通过配置,让push不直接push到git repo,而是push到girrit上。
3.2 设置gerrit push:git config remote.origin.push refs/heads/*:refs/for/*
【注】如果使用Android Studio Gerrit插件,可以省略该步骤。
配置完之后,再git push
就OK了。
这行命令的意思是,当执行push命令时,将会推送到refs/for/当前head所在的分支上,其实就是gerrit维护的暂存分支。
push成功后,网页上会有如下信息:

push到gerrit上成功后,需要Integrator在网页上review code,通过code,push才会纳入git repo
3.3 review code

3.4 submit code

完整的push逻辑到此结束!
4. Android Studio 使用Gerrit
完成上面的各项配置之后,可以再Android Studio中执行gerrit push
4.1 安装Gerrit插件

4.2 推送的时候勾上gerrit
勾上gerrit你会发现推送的地址是origin:refs/for/<branch_name>, 比不勾多一个
refs/for
,表示会推送到gerrit上。
参考链接:
【Gerrit】Gerrit工作流程及使用手册
网友评论