首页 > 其他 > 详细

git 的 pull、fetch、merge

时间:2017-01-18 09:35:53      阅读:390      评论:0      收藏:0      [点我收藏+]

1.pull = fetch + merge

技术分享

 

In the simplest terms, git pull does a git fetch followed by a git merge.

You can do a git fetch at any time to update your remote-tracking branches under refs/remotes/<remote>/.

This operation never changes any of your own local branches under refs/heads, and is safe to do without changing your working copy. I have even heard of people running git fetch periodically in a cron job in the background (although I wouldn‘t recommend doing this).

git pull is what you would do to bring a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.

 

2. merge VS rebase

技术分享

2.1merge命令

把origin分支上的修改拉下来并且和你的修改合并;产生一个合并的提交(merge commit):

2.2rebase命令

把你的分支里的每个提交(commit)取消掉,并且把它们临时保存为补丁(patch)(.git/rebase目录),然后把你的分支更新到最新的origin分支,最后把保存的这些补丁应用到你的分支上。

在rebase的过程中,也许会出现冲突(conflict),Git会停止rebase并会让你去解决 冲突;在解决完冲突后,用"git-add"命令去更新这些内容的索引(index), 然后,你无需执行 git-commit,只要执行:

$ git rebase --continue

这样git会继续应用(apply)余下的补丁。

在任何时候,你可以用--abort参数来终止rebase的行动,你的分支会回到rebase开始前的状态。

$ git rebase --abort

 

3. git merge VS git merge --no-ff

git merge 在没有冲突的时候不会生成新的commit。

如果想在没有冲突的情况下也自动生成一个commit,记录此次合并就可以用:git merge --no-ff命令。

技术分享

 

git 的 pull、fetch、merge

原文:http://www.cnblogs.com/yuyutianxia/p/6295474.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!