1.注冊
1.1 主頁點擊首頁Become

1.2 點擊頁面最下面的Regitster New Account
1.3 填寫注冊表格
Add SSH Public Key這一步可以點擊【4】看說明:
打開C:\Users\Administrator.ssh目錄中的id_rsa.pub(SSH公鑰)文件,復(fù)制其內(nèi)容粘貼到【5】,點擊【6】添加,點擊continue完成注冊。

2.clone項目
2.1 在.ssh目錄下放入管理員提供的config文件(管理員提供)。

第一次使用如果沒在.ssh中配置config文件的話,執(zhí)行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,輸入上一步出現(xiàn)的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多一個環(huán)節(jié),就是圖中那只鳥。
一般的contributor沒有權(quán)限直接將代碼push到git repo上,直接push會提示沒有push權(quán)限。
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 設(shè)置gerrit push:git config remote.origin.push refs/heads/*:refs/for/*
【注】如果使用Android Studio Gerrit插件,可以省略該步驟。
配置完之后,再git push就OK了。
這行命令的意思是,當(dāng)執(zhí)行push命令時,將會推送到refs/for/當(dāng)前head所在的分支上,其實就是gerrit維護的暫存分支。
push成功后,網(wǎng)頁上會有如下信息:

push到gerrit上成功后,需要Integrator在網(wǎng)頁上review code,通過code,push才會納入git repo
3.3 review code

3.4 submit code

完整的push邏輯到此結(jié)束!
4. Android Studio 使用Gerrit
完成上面的各項配置之后,可以再Android Studio中執(zhí)行g(shù)errit push
4.1 安裝Gerrit插件

4.2 推送的時候勾上gerrit
勾上gerrit你會發(fā)現(xiàn)推送的地址是origin:refs/for/<branch_name>, 比不勾多一個
refs/for,表示會推送到gerrit上。
參考鏈接:
【Gerrit】Gerrit工作流程及使用手冊