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
相关推荐
2401_853448233 小时前
Git安装流程和基础使用步骤
git·github
Sagittarius_A*9 小时前
Web 安全之 Git 泄露:原理剖析 + CTFHub Log/Stash/Index 全题型解法
git·安全·web安全
lazy H9 小时前
从入门到日常开发,一篇文章掌握 Git 核心操作
git·后端·学习·github
zzqssliu17 小时前
煤炉自动代拍系统的队列设计与超时控制机制
git·github
一支绝命钩17 小时前
FPGA工程Git常用操作手册
git
不搞学术柒柒21 小时前
Git新功能完整开发提交流程
git
午安~婉1 天前
Git中SSH连接
前端·git·gitee
888CC++1 天前
VS Code Git 工作树:解锁多分支并行开发新体验
git
阿虎儿1 天前
Git exclude 功能解析
git
隔窗听雨眠1 天前
VS Code Git工作树:多分支并行开发的完整实践方案
git