Gerrit/Git常用操作命令

push到服务器,没有code review

bash 复制代码
git push origin HEAD:refs/heads/<branch_name>

push到服务器,需要code review

bash 复制代码
git push origin HEAD:refs/for/<branch_name>

push到draft master

bash 复制代码
git push origin HEAD:refs/drafts/master

删除服务器上的branch

bash 复制代码
git push origin --delete <branch_name>

基于某个commit切branch

bash 复制代码
git checkout -b <branch_name> <commit_id>

merge之后更新本地代码

bash 复制代码
git pull --rebase 或者 git pull -r

查看commit的代码行数

bash 复制代码
git log --stat .

修改commit提交者

bash 复制代码
git commit --amend --author shusheng.zhang@1234.com

修改commit提交时间

bash 复制代码
git commit --amend --data="2022-11-29T09:51:07"

更新子模块

bash 复制代码
git submodule update

依据别人的gerrit link开发

  1. 点击gerrit link左上角download,复制checkout命令到本地terminal中执行

  2. 执行完成会需要执行git checkout -b <branch_name>来创造自己的本地branch

  3. 如果自己单独开发,执行如下命令

    bash 复制代码
    1. git push origin HEAD:refs/heads/<branch_name> #创建属于自己的远端branch
    2. git add <changed_file>
    3. git commit -m <commit_msg>
    4. git push origin HEAD:refs/for/<branch_name> #push到远端自己的branch
  4. 如果是希望修改别人的代码,执行如下命令

    bash 复制代码
    1. git add <changed_file>
    2. git commit -m <commit_msg>
    3. git push origin HEAD:refs/for/<old_branch_name> #old_branch_name是你download的时候的branch name
相关推荐
雪的季节8 小时前
团队 Git 协作完整教程(企业级标准流程)
git
czhc11400756639 小时前
6.4:git
git
Rain5099 小时前
实战:搭建 AI Code Review 自动化流水线
前端·人工智能·git·ci/cd·自动化·ai编程·代码复审
zzzzzz3109 小时前
GitHub 今日爆火!headroom:一个帮你省 60-95% Token 的 AI Agent 上下文压缩神器
git·机器学习·github
张小凡vip11 小时前
gitlab的ci配置文件yaml参数说明
git·ci/cd·gitlab
搬砖的前端11 小时前
AI工具集:Git提交时使用AI进行CodeReview如何在前端应用构建NPM包
前端·人工智能·git·npm·codeview
ZXF_H11 小时前
Git clone 时遇到fatal: protocol ‘http‘ is not supported问题解决方法
git
傻啦嘿哟11 小时前
日志分析:利用OpenClaw日志排查“403”和“503”错误
java·git·github
摆烂菜鸡沧99612 小时前
【自用记录】修改GitHub提交历史作者
git·github
佳木逢钺21 小时前
Git分支强制覆盖与冲突解决实战记录
git·源代码管理