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

相关推荐
CC码码3 小时前
管理你的多个 Git 密钥(多平台多账号)
git·gitlab·github
CC码码3 小时前
管理你的多个 Git 密钥(单平台多账号)
git·gitlab·github
大卫小东(Sheldon)3 小时前
GIM 1.5发布了! 支持Windows系统了
git·ai·rust
flying jiang3 小时前
将大仓库拆分为多个小仓库
git
李boyang10 天前
Git(四):远程操作
git
荻野泽溪10 天前
Git新建分支并同步到远程
git
漫步企鹅10 天前
【Git】新建一个远程分支的常规操作
git·新建远程分支
潇-xiao10 天前
Linux下的版本控制器Git(15)
linux·笔记·git
@昵称不存在10 天前
Git学习
git·学习
pe7er10 天前
⛔️⛔️⛔️丢弃本地commit,强制采用远端代码
git