在git中,获取与pull相比有何不同,以及merge是如何与rebase不同的? [英] In git how is fetch different than pull and how is merge different than rebase?
问题描述
- git fetch vs pull
- git合并与rebase
抓取vs拉
fetch
将从远程*分支下载任何更改,更新您的存储库数据,但不改变本地*分支。
有什么不同? 给出以下历史记录: 合并 pull 将执行
fetch
,另外
$ b pull
更新您的本地分支与拉动分支的变化。 fetch
不会推进您的本地分支。
合并vs rebase
C --- D --- E本地
/
A --- B --- F --- G remote
merge
一起加入两个发展历史。它通过在远程分支之上分叉后重播本地分支上发生的更改并将结果记录在新提交中来实现此目的。此操作保留了每次提交的祖先。
C --- D --- E本地
/ \
A --- B --- F --- G --- H remote
rebase
将接受您本地存在的提交分支并将其重新应用于远程分支之上。这个操作重写本地提交的祖先。
C' - D' - E'本地
/
A --- B --- F- --G remote
有什么区别?合并不会改变提交的祖先。 rebase
会重写您本地提交的血统。
$ b *
这个解释假定当前分支是本地分支,并且分支指定为 fetch
, pull
, merge
或 rebase
是一个远程分支。这是通常的情况。例如, pull
将从指定的分支下载任何更改,更新您的存储库并
I just cant understand this. I been reading a lot on the web and books and something is just not staying in my head. Can someone please give me the dummy version of the following:
- git fetch vs pull
- git merge vs rebase
fetch vs pull
fetch
will download any changes from the remote* branch, updating your repository data, but leaving your local* branch unchanged.
pull
will perform a fetch
and additionally merge
the changes into your local branch.
What's the difference? pull
updates you local branch with changes from the pulled branch. A fetch
does not advance your local branch.
merge vs rebase
Given the following history:
C---D---E local / A---B---F---G remote
merge
joins two development histories together. It does this by replaying the changes that occurred on your local branch after it diverged on top of the remote branch, and record the result in a new commit. This operation preserves the ancestry of each commit.
The effect of a merge
will be:
C---D---E local / \ A---B---F---G---H remote
rebase
will take commits that exist in your local branch and re-apply them on top of the remote branch. This operation re-writes the ancestors of your local commits.
The effect of a rebase
will be:
C'--D'--E' local / A---B---F---G remote
What's the difference? A merge
does not change the ancestry of commits. A rebase
rewrites the ancestry of your local commits.
*
This explanation assumes that the current branch is a local branch, and that the branch specified as the argument to fetch
, pull
, merge
, or rebase
is a remote branch. This is the usual case. pull
, for example, will download any changes from the specified branch, update your repository and merge
the changes into the current branch.
这篇关于在git中,获取与pull相比有何不同,以及merge是如何与rebase不同的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!