合并issue3分支的时候,使用rebase可以使提交的历史记录显得更简洁。

现在暂时取消刚才的合并。

$ git reset --hard HEAD~

切换到issue3分支后,对master执行rebase。

$ git checkout issue3
Switched to branch 'issue3'
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: 添加pull的说明
Using index info to reconstruct a base tree...
<stdin>:13: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging myfile.txt
CONFLICT (content): Merge conflict in myfile.txt
Failed to merge in the changes.
Patch failed at 0001 添加pull的说明When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".

和merge时的操作相同,修改在myfile.txt发生冲突的部分。

连猴子都懂的Git命令
add 把变更录入到索引中
<<<<<<< HEAD
commit 记录索引的状态
=======
pull 取得远端数据库的内容
>>>>>>> issue3

rebase的时候,修改冲突后的提交不是使用commit命令,而是执行rebase命令指定 --continue选项。若要取消rebase,指定 --abort选项。

$ git add myfile.txt
$ git rebase --continue
Applying: 添加pull的说明

这样,在master分支的issue3分支就可以fast-forward合并了。切换到master分支后执行合并。

$ git checkout master
Switched to branch 'master'
$ git merge issue3
Updating 8f7aa27..96a0ff0
Fast-forwardmyfile.txt |    1 +1 files changed, 1 insertions(+), 0 deletions(-)

myfile.txt的最终内容和merge是一样的,但是历史记录如下。

from: https://backlog.com/git-tutorial/cn/stepup/stepup2_8.html

用git rebase合并相关推荐

  1. git 代码没了,git rebase 合并提交记录,git stash

    xx 问题 git合并提交记录 创建提交记录 合并提交记录 rebase有冲突 合并后的本地路径提交到远程 其中的参数 pick 改变提交 5.txt 和 4.txt 的顺序 删除某一个提交 rewo ...

  2. [Git Rebase] Git Rebase 合并提交(命令操作 SourceTree 操作)

    前言 在开发过程中, 我们有的时候会有代码提交失误的情况. 在前一章, 我们介绍了git push - - force命令. 本章我们介绍git rebase命令及 SourceTree内的相关操作. ...

  3. 使用Git rebase合并多条提交记录commit。以及使用 git commit amend本地提交直接合并到远程已有commit的用法

    需求场景一 : 对某个小的功能点进行多次反复的修改提交,且已经提交到远程,导致commit记录过多,太过于杂乱无章,想要精简合并一些提交记录. 场景还原: 比如下图4个git commit记录,log ...

  4. git rebase 合并中间的提交

    1.准备数据,每次提交一行 2.rebase 3.将version3合并到version2 fixup也可,就是不能修改提交信息 pick:保留该commit(缩写:p) reword:保留该comm ...

  5. idea git rebase ---- 合并多个提交到某个分支(实用)

    如图,需要将这些提交合并到另一个分支 先复制提交号 打开rebase 把刚刚的提交号填入 选择自己需要的合并方式 pick:按原样应用所选的提交.edit:选择在应用此提交之前编辑受此提交影响的文件. ...

  6. git rebase VS git merge? 更优雅的 git 合并方式值得拥有

    写在前面 如果你不能很好的应用 Git,那么这里为你提供一个非常棒的 Git 在线练习工具 Git Online ,你可以更直观的看到你所使用的命令会产生什么效果 另外,你在使用 Git 合并分支时只 ...

  7. 使用git rebase和merge合并特定commits到master分支

    可能大家知道如何使用cherry-pick从一个分支合并特定的commits到另一个分支,但是这个方法不能保留原始的提交信息(比如提交时间线等),而如果要保留合并过来的commits的所有提交信息,那 ...

  8. [Git] Git整理(四) git rebase 的使用

    概述 在之前总结分支相关内容时说道,合并两个分支的提交可以使用git merge,然而除了这种方式之外,还有一种方式就是使用git rebase,这两种方式的最终结果都相同,但是合并历史却不同:git ...

  9. 合并代码还在用git merge吗?我们都用git rebase!

    欢迎关注方志朋的博客,回复"666"获面试宝典 git merge 和 git rebase的区别 目的都是将一个分支的 commit 合并到到另外一个分支中去. git merg ...

最新文章

  1. (笔记)Mysql命令select from:查询表中的数据(记录)
  2. unittest单元测试框架之unittest案例(二)
  3. 刷题≠学好数学,近百位名校名师告诉你,数学是怎么学好的?
  4. JDDroppableView
  5. android流媒体架构,基于Android平台的流媒体播放器的设计与实现
  6. LaTex下载安装详解
  7. 通过v$bgprocess查看后台进程
  8. html毕业设计任务要求,毕业设计任务及进度安排|毕业设计进度安排
  9. 前端leader找我谈心:我是如何从刚毕业的前端菜鸟一步步成长为前端工程师的?
  10. linux进行挂载Nas存储
  11. C语言为何不会过时?你需要掌握多少种语言?
  12. 轻量型网络之MobileNetV2: Inverted Residuals and Linear Bottlenecks论文学习
  13. 我是如何记笔记的--谈谈自己的学习方法
  14. Cygwin 完全下载及安装
  15. Python 正则表达式 match、findall、search
  16. 《软件测试》第十章 外国语言测试
  17. hive插入多条数据sql_30分钟入门 Hive SQL(HQL 入门篇)
  18. 短视频怎么追热点?怎样才能快速涨粉?
  19. you-get:使用命令行工具下载网络资源,可下载 B 站视频
  20. 【实用工具】RD Clinet使用教程之ipad连接windows

热门文章

  1. Streaming Big Data: Storm, Spark and Samza--转载
  2. SHELL网络爬虫实例剖析--转载
  3. How to allow/block PING on Linux server – IPTables rules for icmp---reference
  4. window xp Apache与Tomcat集群配置--转载
  5. 几种常用的加密方式简单介绍
  6. 机器学习算法加强——回归
  7. 将要改变IT世界的的docker技术是什么?
  8. 关于数据科学,书上不曾提及的三点经验
  9. 实战SSM_O2O商铺_16【商铺注册】前后端联调验证整体模块功能
  10. oracle中primary,oracle中如何 Primary key自增