原文:http://www.cnblogs.com/kevingrace/p/5896706.html

使用下面的关系区别这两个操作:
git pull = git fetch + git merge
git pull --rebase = git fetch + git rebase

现在来看看git merge和git rebase的区别。

假设有3次提交A,B,C。

在远程分支origin的基础上创建一个名为"mywork"的分支并提交了,同时有其他人在"origin"上做了一些修改并提交了。

其实这个时候E不应该提交,因为提交后会发生冲突。如何解决这些冲突呢?有以下两种方法:

1、git merge
用git pull命令把"origin"分支上的修改pull下来与本地提交合并(merge)成版本M,但这样会形成图中的菱形,让人很困惑。

2、git rebase
创建一个新的提交R,R的文件内容和上面M的一样,但我们将E提交废除,当它不存在(图中用虚线表示)。由于这种删除,小李不应该push其他的repository.rebase的好处是避免了菱形的产生,保持提交曲线为直线,让大家易于理解。

在rebase的过程中,有时也会有conflict,这时Git会停止rebase并让用户去解决冲突,解决完冲突后,用git add命令去更新这些内容,然后不用执行git-commit,直接执行git rebase --continue,这样git会继续apply余下的补丁。
在任何时候,都可以用git rebase --abort参数来终止rebase的行动,并且mywork分支会回到rebase开始前的状态。

git pull --rebase的使用的更多相关文章

  1. 聊下git pull --rebase

    有一种场景是经常发生的. 大家都基于develop拉出分支进行并行开发,这里的分支可能是多到数十个.然后彼此在进行自己的逻辑编写,时间可能需要几天或者几周.在这期间你可能需要时不时的需要pull下远程 ...

  2. 关于git中git pull --rebase中的一些坑

    在公司里面,每次我更改完代码,准备pull最新代码时,总是会遇到各种各样的问题.,因为对应的问题不同,解决方法很多.但是比较通用的办法还是有的: git pull --rebase   //报错时 g ...

  3. git pull --rebase

    git reset --hard orgin/master $ git push bit 1.8-subchannels To git@bitbucket.org:cms.git ! [rejecte ...

  4. Difference between git pull and git pull --rebase

    个人博客地址:  http://www.iwangzheng.com/ 推荐一本非常好的书 :<Pro Git>  http://iissnan.com/progit/ 构造干净的 Git ...

  5. git pull --rebase 做了什么? 以及 Cannot rebase: You have unstaged changes 解决办法

    最近刚学 git rebase,觉得很牛逼的样子, 结果今天就被打脸了. git pull --rebase 报错: Cannot rebase: You have unstaged changes ...

  6. 对比git pull和git pull --rebase

    1.使用下面的关系区别这两个操作:git pull = git fetch + git mergegit pull --rebase = git fetch + git rebase 2 一.基本 g ...

  7. git pull以及git pull --rebase

    git pull的作用是将远程库中的更改代码合并到当前分支中,默认为:git fetch + git merge git fetch 的作用就相当于是从远程库中获取最新版本到本地分支,不会自动进行gi ...

  8. 简单对比git pull和git pull --rebase的使用

    使用下面的关系区别这两个操作:git pull = git fetch + git mergegit pull --rebase = git fetch + git rebase 现在来看看git m ...

  9. 【Git】git pull和git pull --rebase的使用

    git pull = git fetch + git mergegit pull --rebase = git fetch + git rebase 现在来看看git merge和git rebase ...

  10. git fetch 、git pull 与 git pull --rebase

    1. git fetch 与 git pull 都是从远程拉取代码到本地,git fetch只是拉取到本地,git pull不仅拉取到本地还merge到本地分支中.所以git pull是git fet ...

随机推荐

  1. GridView 绑定数据的常用指定格式。

    形式 语法 结果 注释 数字 {0:N2} 12.36   数字 {0:N0} 13   货币 {0:c2} $12.36   货币 {0:c4} $12.3656   货币 "¥{0:N2 ...

  2. emacs配置buffer的快捷键

    emacsConfig/buffer-setting.el (global-set-key (kbd "<M-left>") 'previous-buffer) (gl ...

  3. Android中Parcelable与Serializable接口用法

    转自: Android中Parcelable接口用法 1. Parcelable接口 Interface for classes whose instances can be written to a ...

  4. HDU 1251 统计难题(字典树)

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  5. jvectormap地图开发和制作任意国家地图

    jvectormap官网上提供了世界地图和很多国家的地图,但不是所有国家的地图都有,比如沙特阿拉伯的国家地图就没有,怎么办呢? 在http://www.amcharts.com/svg-maps/上下 ...

  6. modelsim 仿真xilinx fir ip

    到现在不管fir ip 用的对不对,但是在使用modelsim是可以仿真fir ip的. 具体步骤: 1.仿真库,添加到modelsim目录配置文件: 2.将这个文件中的: :List of dyna ...

  7. cursor: pin S产生原理及解决方法

    转自:http://www.dbafree.net/?p=778 今天晚上在一个比较重要的库上,CPU严重的冲了一下,导致DB响应变慢,大量应用连接timeout,紧接着LISTENER就挂了,连接数 ...

  8. 好记性不如烂笔头--linux学习笔记9练手写个shell脚本

    #!/bin/bash #auto make install httpd #by authors baker95935 #httpd define path variable H_FILES=http ...

  9. 【CentOS 6.5】QtCreator启动时关于dbus-1的错误解决方法

    关于上篇文章留下的启动QtCreator提示:dbus_connection_can_send_type的错误,解决办法: 更新dbus版本来解决.. 首先去 http://dbus.freedesk ...

  10. Python中的strip()函数的用法

    函数:string.strip() Python strip() 方法用于移除字符串头尾指定的字符(默认为空格). 一.函数说明 strip() 语法:str.strip([rm]); 参数说明 rm ...