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 [email protected]

修改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
相关推荐
我的golang之路果然有问题5 小时前
给git配置SSH(github,gitee)
经验分享·笔记·git·学习·gitee·ssh·github
漫步企鹅6 小时前
[Git] Git Stash 命令详解
git·git push·git pull·git commit·git pull rebase
船长@Quant8 小时前
协作开发攻略:Git全面使用指南 — 第二部分 高级技巧与最佳实践
git·版本控制·源代码管理·协作开发
用户126538387051210 小时前
github 和 gitee 配置问题及相关问题解决
git·github
极小狐10 小时前
极狐GitLab Git LFS 速率限制如何设置?
运维·git·ssh·gitlab·github
极小狐10 小时前
如何解决极狐GitLab 合并冲突?
人工智能·git·机器学习·gitlab
一袋米扛几楼9811 小时前
【GIT】github中的仓库如何删除?
git·github
hjm470219211 小时前
GIT 使用小记
git
程序猿chen21 小时前
JVM考古现场(二十五):逆熵者·时间晶体的永恒之战(进阶篇)
java·jvm·git·后端·程序人生·java-ee·改行学it
biubiubiu07061 天前
git提交
git