记录git rebase用法
git 是基于文件系统的版本管理工具,文档和详细介绍可以查看git
一.git commit --amend
如果你对文件做了修改需要和上一次的修改合并为一个change
git add .
git commit --amend
二.git rebase
在 Git 中整合来自不同分支的修改主要有两种方法:
merge以及rebase。 在本节中我们将学习什么是“变基”,怎样使用“变基”,并将展示该操作的惊艳之处,以及指出在何种情况下你应避免使用它 -- 参考https://git-scm.com/book/zh/v2/Git-%E5%88%86%E6%94%AF-%E5%8F%98%E5%9F%BA
git rebase -i HEAD~n
列出最近的几次change(从old -> new),并且左边包含可以进行的操作
1 pick 7a802ef test4
2 pick 0eaa6ba for #noTicket 1
3 pick 999e310 for #noTicket
4 pick 83bb011 for #ceshi
5
6 # Rebase c3ff658..83bb011 onto c3ff658 (4 command(s))
7 #
8 # Commands:
9 # p, pick = use commit
10 # r, reword = use commit, but edit the commit message
11 # e, edit = use commit, but stop for amending
12 # s, squash = use commit, but meld into previous commit
13 # f, fixup = like "squash", but discard this commit's log message
14 # x, exec = run command (the rest of the line) using shell
15 #
16 # These lines can be re-ordered; they are executed from top to bottom.
17 #
18 # If you remove a line here THAT COMMIT WILL BE LOST.
19 #
20 # However, if you remove everything, the rebase will be aborted.
21 #
22 # Note that empty commits are commented out
在commands里面包括了几个命令,简单介绍下
r, reword = use commit, but edit the commit message
简单的理解就是修改此commit的commit message
1 pick 7a802ef test4
2 r 0eaa6ba for #noTicket 1
3 pick 999e310 for #noTicket
4 pick 83bb011 for #ceshi
保存后进入编辑commit message模式
1 for #noTicket 1
2
3 测试
4
5 Change-Id: Ia0542f3b9292df45213c567948ff6f797858426f
保存退出后对应change的message就修改成功了
edit : use commit, but stop for amending 选取此commit,并且保存退出后提交的修改将amend此commit
1 pick 7a802ef test4
2 e 73c9c8f for #noTicket 1
3 pick 5cc2966 for #noTicket
4 pick 437ba25 for #ceshi
保存退出后:
gerrit-workshop git:(master) git rebase -i HEAD~4
Stopped at 73c9c8f1b281b8636ae990f58d1fba6260efb589... for #noTicket 1
You can amend the commit now, with git commit --amend Once you are satisfied with your changes, run git rebase --continue
之后做的修改再次amend后会基于这个commit
git add . 将所有修改提交到暂存区 git commit --amend 将暂存区的修改提交到本地仓库修改你刚才选中的change git rebase --continue 回到最初的状态
第三个 squash use commit, but meld into previous commit ,将这个change合并到上一次change中,并且会保留这个change的message,相当于将两个commit合并为一个
第四个 fixup 和squash一样,但是不会保留change的message
记录git rebase用法的更多相关文章
- git第七节---git merge和git rebase
# git merge和git rebase 都可以进行分支合并 #git merge 合并后保留记录两个分支的记录 #git rebase合并后会展示成一个分支的记录,另一个分支的提交实际生成了一个 ...
- git rebase和git merge的用法
http://softlab.sdut.edu.cn/blog/subaochen/2016/01/git-rebase%E5%92%8Cgit-merge%E7%9A%84%E7%94%A8%E6% ...
- git rebase的用法
改变基 一个git库,开发人员在master分支的Bcommit的时候,创建了一个dev分支,此时Bcommit是dev分支的基,然后分别进行两个分支的开发. 进行到master提交了Dcommit, ...
- Git merge && git rebase的用法
Git merge的用法: git merge Dev // Dev表示某分支,表示在当前分支合并Dev分支 git merge -m “Merge from Dev” Dev //-m可以加上m ...
- git rebase的使用: 合并多次commit记录; rebase一个分支的起点
合并多次commit记录: good:https://blog.csdn.net/csdlwzy/article/details/83379546 使用 git log 命令查看提交历史: 想要合并前 ...
- [转]【Git】rebase 用法小结
https://www.jianshu.com/p/4a8f4af4e803 本文主要参考 https://git-scm.com/docs/git-rebase rebase在git中是一个非常有魅 ...
- git命令之git rebase 的用法
rebase 假设你现在基于远程分支"origin",创建一个叫"mywork"的分支. $ git checkout -b mywork origin 现在我 ...
- Git的用法
Git的用法 Git 的也可以理解为版本控制器.版本控制器(维基的解释):维护工程蓝图的标准作法,能追踪工程蓝图从诞生一直到定案的过程.此外,版本控制也是一种软件工程技巧,借此能在软件开发的过程中,确 ...
- git rebase 的使用
rebase 在 Git 中整合来自不同分支的修改主要有两种方法:merge 以及 rebase. 在本节中我们将学习什么是“rebase”,怎样使用“rebase”,并将展示该操作的惊艳之处,以及指 ...
随机推荐
- appium-手势密码实现-automationName 是automator2
上一篇博客已经说了 appium-手势密码实现-automationName 是Appium的情况 下面就说一下automator2的情况: 手势密码的moveTo方法的参数进行了改变. 参数是相对于 ...
- hnust py road
问题 C: Py Road 时间限制: 1 Sec 内存限制: 128 MB提交: 125 解决: 34[提交][状态][讨论版] 题目描述 Life is short,you need Pyth ...
- Spring 笔记(三)Bean 装配
前言 Spring 有两大核心,也就分成两份笔记分别记录. 其一是管理应用中对象之间的协作关系,实现方式是依赖注入(DI),注入依赖的过程也被称为装配(Wiring). 基于 JavaConfig 的 ...
- JavaScript里面的条件、循环语句以及异常处理
1.JavaScript里面条件语句主要有两种形式 if(条件){ ... }else if(条件){ ... }else{ ...} switch(变量名): case 值1://如果变量名为值1, ...
- Python读写tap设备
#!/usr/bin/python import os import struct import fcntl import binascii TUNSETIFF = 0x400454ca IFF_TA ...
- idea中新建的web项目不能新建servlet
============ ======================================================================== 在新建的“ java ”源文 ...
- hdu 1007 Quoit Design (最近点对问题)
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- 项链 [FFT]
题面 思路 这题很像bzoj4827礼物 还是一样的思路,我们把$y$倍长,$y[i+k]=y[i]+n$ 然后令$f(s,c)$表示从$y$的第$s$个开始匹配,位置偏移量为$c$的答案 可以得到$ ...
- [经验分享]Windows系统下生成IOS证书
我使用ApiCloud开发APP,开发后需要生成IOS的证书才能在项目开发控制台中进行编译,于是我在网上大海捞针似的寻找办法. 官方文档提供了使用苹果系统下生成IOS证书的步骤,对于我这个没有imac ...
- angular组件--tips提示功能
将组件封装起来在项目中开发很实用,之前遭遇过一次痛苦的经历,那阵子改的要吐血了.常用的组件封装起来,改公共的地方,往往多处受用. 例如:我在项目中引用 tips.text('加载中...',fals ...