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

相关推荐
即使再小的船也能远航5 小时前
【Git】实用Git操作指南:从入门到高效协作
git
<但凡.15 小时前
Git 完全手册:从入门到团队协作实战(4)
git·bash
SugarPPig16 小时前
Git 创建一个完全没有提交历史的 master 分支
git
lb29172 天前
git的使用,推送仓库github
git·github
躲在云朵里`2 天前
Git的使用
大数据·git·elasticsearch
悟能不能悟2 天前
在 IntelliJ IDEA 中打开这个用于设置 Git 用户名(Name)和邮箱(Email)的特定弹窗
java·git·intellij-idea
威威猫的栗子3 天前
Git 使用全指南:从配置到免密登录
大数据·git·vscode
Casia_Dominic3 天前
【tmux无法使用鼠标滚轮滚动页面的问题】解决方案
linux·git·github·tmux
Justice link3 天前
Nginx和Apache的区别
git
物联网软硬件开发-轨物科技3 天前
【轨物方案】分布式光伏电站运维升级智能化系列:老电站的数智化重生
运维·人工智能·分布式·git