Git: pull vs. fetch→pull
我从来没有对这个问题有过明确的答案。
很长一段时间以来,在同事的建议下,我一直在这样做:
1 2 | git fetch origin git pull origin <mybranch> |
我听说(并且已经看到)如果你不先做
但我在网上看到的是,
所以我要找的是一些明确的文档,描述了观察到的
我们应该把这个作为一个复制品关闭,但在这之前,让我看看我能不能把它塞进。
虽然
明确地:
或:
(或各种类似的变体)运行,不是普通的
这与Git版本1.8.4相比,差异较小:
git fetch origin master unlikegit fetch origin orgit fetch
did not updaterefs/remotes/origin/master ; this was an early
design decision to keep the update of remote tracking branches
predictable, but in practice it turns out that people find it more
convenient to opportunistically update them whenever we have a
chance, and we have been updating them when we rungit push which
already breaks the original"predictability" anyway.
换句话说,如果
如果运行
I've been told (and have seen) that git pull does not behave the same way if you do not first do git fetch. You don't get any remote changes.
通常情况下,这不是真的,而git pull从远程控制状态。
But all I see online is that git pull is the equivalent of git fetch followed by git merge. If that were true,
它是!
引用
Incorporates changes from a remote repository into the current branch. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.
我想这就解决了。
So what I'm looking for is some explicit documentation
1 | $ git help pull |
git pull是一个get fetch,然后是git合并。(或者,您可以使用--rebase选项来重新设置基码)。所以不,你不需要在"Git Pull"之前做"Git Fetch"
键入"git help fetch"和"git help pull"以获取说明
Git Fetch将转到指定的存储库,获取被引用的对象(通常是提交),获取它及其所有依赖对象,并将其存储在指定的远程跟踪分支中。然后你可以合并或者从那里重新平衡。Git合并源站/主服务器,或者您可以使用"Git签出源站/主服务器"查看它。