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
相关推荐
徐同保2 小时前
Git Commit message规范(Git提交信息规范)
大数据·git·elasticsearch
chenshiming8022 小时前
如何修改GIT的提交日志注释
git
什么都不会的Tristan3 小时前
使用Git进行版本控制
git
MDY12195 小时前
IDEA如何配置Git
git
CNRio6 小时前
Day 50:Git的高级技巧:使用Git的rebase交互式修改提交历史
大数据·git·elasticsearch
CNRio6 小时前
Day 52:Git的高级技巧:使用Git的bisect定位问题提交
大数据·git·elasticsearch
Tiam-20167 小时前
开发办公工具
git·编辑器·开发工具·敏捷开发
CNRio9 小时前
Day 55:Git的高级技巧:使用Git的worktree管理多个工作目录
大数据·git·elasticsearch
MDY121910 小时前
IDEA推送文件到GIT失败,显示:无法执行Git:无法识别Git可执行文件的版本:无响应
java·ide·git·intellij-idea
CNRio10 小时前
Day 54:Git的高级技巧:使用Git的submodule管理子项目
git