Submmit to Gerrit w/o code review

If you want to submit changes directly without code review, especially when

  1. Import existing repositories, SDK, or other original opensource packages that does not need code review
  2. "git review" command fails due to remote branch does not exist

You can use commands as below instead to bypass code review process.

  1. Add "gerrit" remote if it does not exist, skip this if you have "gerrit" remote.

git remote add gerrit ssh://<username>@<gerrit_server>:29418/<project_name>.git

  1. Push your changes to Gerrit directly without code review.

git push gerrit "branch_name(eg HEAD:ref/for/master)"

eg:

  1. 查看 project name # git config -l (这里就是 prpos-v3.2.0)

  2. git remote -v 查看 remote 的 gerrit 仓库名 没有添加

git remote add gerrit ssh://<username>@<gerrit_server>:29418/<project_name>.git

  1. 推送本地到gerrit

git push gerrit HEAD:refs/heads/master // HEAD 本地最新

eg:git push gerrit HEAD:refs/for/master // 推送最新一笔code 到gerrit review

  1. Step 3 可能会失败

获取Git仓库目录

  1. gitdir=$(git rev-parse --git-dir) // 这里其实就是 .git 目录

从Gerrit服务器下载commit-msg钩 子并安装

  1. scp -p -P 29418 adley_cheng@172.21.67.99:hooks/commit-msg ${gitdir}/hooks/

eg: scp -p -P 29418 adley_cheng@172.21.67.99:hooks/commit-msg .git/hooks/

  1. git commit --amend --no-edit

  2. git push gerrit HEAD:refs/for/master // 再推送

一般需要gerrit review 才上code ,不要轻易 git push

相关推荐
吨吨ai5 天前
ChatGPT Plus / Pro 如何用好 Codex?AGENTS.md、测试闭环与 AI Code Review 实战
人工智能·chatgpt·代码复审
NutShell Wang10 天前
拆解 GitHub gh-stack:堆叠 PR 工作流的设计取舍与工程实现
前端·git·开源·github·代码复审·开发者工具·vibe coding
繁荣的红酒1 个月前
Code Review有什么好处?
代码复审
江畔柳前堤1 个月前
第13章:docker生产环境部署实战
运维·git·docker·容器·代码复审
星落zx2 个月前
在CI/CD流水线里接入多模型自动Code Review,踩坑与方案分享
人工智能·ci/cd·代码复审
zhiSiBuYu05172 个月前
建立 AI 辅助开发的 Code Review 流程实战指南
人工智能·代码复审
hai3152475432 个月前
九章编程法 · 字典引擎【0/1拓扑步进 · 矩阵压缩·终极封版】
人工智能·数学建模·性能优化·动态规划·代码复审·傅立叶分析·极限编程
小马爱打代码2 个月前
Coding及Code Review规范指引
代码复审
Rain5092 个月前
实战:搭建 AI Code Review 自动化流水线
前端·人工智能·git·ci/cd·自动化·ai编程·代码复审
随风丶飘3 个月前
AI Code Review 实测:GitHub Copilot PR Review 与 CodeRabbit,能否替代人工 Review?
人工智能·github·代码复审