带有refspec的Git拉 [英] Git pull with refspec

查看:60
本文介绍了带有refspec的Git拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了这个问题,现在我对此有疑问git pull如何与refpec配合使用:

I read this question , and now I have this doubt as to how git pull work with refpec :

Step 1 : I am on branchA.

Step 2 : I do `git pull origin branchB:branchC` .

Step 3: I notice : 

a) commits from branchB on remote comes and update `remotes/origin/branchC`

b) Then a merge happened. `branchC` was updated with `remotes/origin/branchC`

c) The `branchC` was merged into `branchA`.

现在,我很困惑,因为git pull = git fetch + git merge,那么这里的2合并是怎么发生的呢?步骤b)和步骤c)都合并.

Now, I am confused that since git pull = git fetch + git merge , then how does 2 merge happened here ? Step b) and Step c) are both merge.

推荐答案

在阅读 @ torek-ans-1 和 @ torek-ans-2 [我必须读这本书才能理解git fetch/pull的工作原理]为想要快速获得答案的人发布完整的答案.

Well, after reading @torek-ans-1 and @torek-ans-2 [This is must read to understand the working of git fetch/pull], I feel to post an complete answer to my question for those who want to get it quickly.

首先,问题中的步骤是错误的.这是正确的步骤:

First, the steps in the question are wrong. This is the correct steps :

Step 1 : I am on branchA.

Step 2 : I do `git pull origin branchB:branchC` .

Step 3: I notice : 

a) commits from branchB on remote comes and update `refs/heads/branchC`

b) Then based on `remote.origin.fetch` was used to try to update `remotes/origin/branchB` on our local.

[ Notice that no attempts will be made to update `remotes/origin/branchC`]

c) The `branchC` was merged into `branchA`.

[顺序可能因一个git版本而异]

[Order might vary from one git version to other]

在步骤a)+步骤b)中,没有合并.这称为快速前向更新.也有一种称为快速前向合并"的行为,但是当git merge的行为类似于快速前向更新时,我们说的是快速前向合并.

In step a) + step b) , there is no merge. This is called fast forward update. There is something called fast forward merge too which behaves like this but we say fast forward merge when git merge behaves like a fast forward update.

在步骤a)+步骤b)中,没有调用git merge.因此,我们将其称为快速前向更新,而不是快速前向合并.

Here in step a)+ step b) no git merge is called . Hence, we call it fast forward update and not fast forward merge.

将在步骤c)中调用git merge.

Step c) is where git merge will be called.

简而言之:git pull origin branchB:branchC= git fetch origin branchB:branchC ((a) + (b))+ git merge branchC (c)

现在我的问题是为什么2个合并称为?

Now my question was why 2 merge called ?

没有2 merge.在步骤c)中只有1个合并.是的,有2个快速转发更新,而git fetch可以做到.

There are not 2 merge . There is only 1 merge in step c). Yes, there are 2 fast forward update and git fetch does them.

这篇关于带有refspec的Git拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆