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

相关推荐
Async Cipher1 小时前
Git 安装、配置
git
CoderJia程序员甲5 小时前
GitHub 热榜项目 - 日榜(2026-01-24)
git·ai·开源·llm·github
莫问前路漫漫5 小时前
Electerm 连接远程服务器完整指南
运维·服务器·git
鸣弦artha6 小时前
TabBar标签页组件详解
linux·git·ubuntu
小林up9 小时前
Ubuntu访问不了Git解决办法
linux·git·ubuntu
月初,1 天前
Git 常用操作大全(超详细教程)一文教会你完全使用Git
大数据·git·elasticsearch
李少兄1 天前
Git 忽略文件机制:.gitignore 与 .git/info/exclude
java·git·elasticsearch
github.com/starRTC1 天前
Claude Code中英文系列教程17:将Claude Code集成在GitLab工作流里面
git·gitlab·github
CCC:CarCrazeCurator1 天前
git merge与rebase的区别及实操心得体会
git
草莓熊Lotso1 天前
Qt 控件美化与交互进阶:透明度、光标、字体与 QSS 实战
android·java·开发语言·c++·人工智能·git·qt