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
相关推荐
weixin_704266059 小时前
IDEA 整合 Git 并上传代码到 CSDN GitCode 超详细教程
git·intellij-idea·gitcode
芝士就是力量啊 ೄ೨9 小时前
Git使用教程(如何使用VSCode+Git+Gitee对项目进行版本控制)
git·vscode·gitee
OYangxf10 小时前
Git工作流用法
git
___波子 Pro Max.1 天前
Git Remote 仓库地址变更
git
ModestCoder_1 天前
Git 忽略所有 `.xlsx`,但保留指定 Excel 文件的方法
git·excel
阡陌..1 天前
202605新版git_2.54.0常用操作指令
大数据·git·elasticsearch
会笑的小熊1 天前
VScode项目推送到git仓库
ide·git·vscode
zhangfeng11331 天前
宝塔服务器完全可以安装 Git,进行版本管理,而且非常简单
运维·服务器·人工智能·git·编程
Bdygsl1 天前
Git(1)—— 基本理解与使用
git
JiaWen技术圈1 天前
增量静态再生(ISR)详解:Next.js 中的实现与应用
javascript·git·ubuntu