gerrit代码review使用基本方法

1、repo拉取代码

repo init -u ssh://gerrit.senseauto.com/senseauto_manifest -b develop -m senseauto-config.xml --repo-url=ssh://gerrit.senseauto.com:29418/senseauto_repo --repo-branch=develop --no-repo-verify

repo sync -j4

repo forall -j 4 -p -c 'git lfs pull'

2、修改代码

git pull可以拉取所有分支的代码

git checkout branch-dev(切换到开发分支,如果和origin名称一样会自动关联远程分支,可以用git branch -vv或者git log确认)

git add xx

git commit -m "xx"

git push origin HEAD:refs/for/develop%topic=test-topic

3、过CI

jenkins上通过特定的CI pipeline,

通过build with param绑定分支 以及topic

4、merge dev

添加代码reviewer确认

或者通过reply 添加确认,无误后进行merge submit。

5、合入release-xxx分支

通过cherry-pick方式

git checkout release-xxx分支

在gerrit上merge成功的页面找到download path,选择cherry-pick

git fetch "ssh://yangyuxin@gerrit.senseauto.com:29418/senseauto_modules_perception_camera" refs/changes/19/178319/3 && git cherry-pick FETCH_HEAD

如果没有冲突,则成功合入,git push即可

git push origin HEAD:refs/for/release-xxx%topic=test-topic

如果有冲突,则进行修改后,git cherry-pick continue

参考:https://www.ruanyifeng.com/blog/2020/04/git-cherry-pick.html

紧急处理

  • 如果合入错误分支,可以使用版本回退

    git reset --hard HEAD~3 # 回退上上上一个版本

    git reset --hard bae128 # 回退到某个版本回退点之前的所有信息。

  • 很多修改的文件丢弃

    git chekout .

    .匹配了所有的文件,相当于git checkout all-files

相关推荐
-拟墨画扇-4 小时前
Git | 分支管理操作
git·gitee·github·gitcode
ModestCoder_4 小时前
Git 版本管理教程
大数据·git·elasticsearch
YMGogre4 小时前
Git 提交信息规范
git
charlie1145141915 小时前
Git团队协作完全入门指南(下)
git
golang学习记7 小时前
Facebook 为什么不用 Git?
git·elasticsearch·facebook
GIS阵地8 小时前
git拉取时报错
大数据·git·elasticsearch
无限进步_10 小时前
C++ Vector 全解析:从使用到深入理解
开发语言·c++·ide·windows·git·github·visual studio
charlee4411 小时前
Git使用经验总结9-Git提交关联到Issue
git·issue
-拟墨画扇-11 小时前
Git | Bug分支操作
git·gitee·github·bug·gitcode
-拟墨画扇-13 小时前
Git | Feature分支操作
git·gitee·github·gitcode