“Git pull response message meaning” 可以翻译为 “Git 拉取响应消息的含义”。

huangapple go评论48阅读模式
英文:

Git pull response message meaning

问题

  1. "From https://github.com/myUserName/myRemote" and "* branch myBranch -> FETCH_HEAD" indicate that Git is providing information about the source and destination of the pull operation. It's showing that it is pulling changes from the specified remote repository (https://github.com/myUserName/myRemote) and updating the local branch named "myBranch" with the changes from the remote branch.

  2. Git does not provide this feedback when you do just git pull because in that case, Git assumes you are pulling from the default remote and the currently checked-out branch. Therefore, it may consider this information to be redundant or less useful, as it's already implied by the context of the command. However, when you specify a remote and branch in the git pull myRemote myBranch command, Git provides more detailed feedback to confirm the source and destination explicitly.

英文:

If I do:

git pull

git responds:

Already up to date.

But if I do:

git pull myRemote myBranch

git responds:

From https://github.com/myUserName/myRemote
* branch            myBranch       -> FETCH_HEAD
Already up to date.

(According to git branch -vv myRemote and myBranch are the defaults.)

Questions:

  1. What does git try to tell me in the part
    From https://github.com/myUserName/myRemote
    * branch myBranch -> FETCH_HEAD
    ?
  2. Why does git not give this feedback if I do just git pull?

(It looks like git wants to tell me it pulled from myRemote > myBranch but in the case git pull myRemote myBranch that feedback seems pretty superfluous while in the case git pull it might actually be useful..)

答案1

得分: 3

首先,这些消息是由Git拉取的“fetch”部分提供的。如果您使用git fetch,您将获得相同的消息。

当您执行:

git pull myRemote myBranch

… 您实际上并没有将远程的myRemote拉取到本地的myBranch

myRemote 是远程存储库的名称,myBranch 是您想从远程拉取回来的远程分支的名称。后一个参数实际上是一个refspec,它允许您指定与可选本地同源关联的源(远程)引用。

您还可以使用通配符*和/或用空格分隔的多个refspecs,从而能够一次性获取多个引用,因此Git为每个引用详细说明了发生的情况。

例如:

git fetch origin master:my_cutty_local_master

… 将获取与origin/master实际相关的一切,然后在其上创建一个名为my_cutty_local_master的本地分支。

因此,Git在这里告诉您的是,在服务器上的myBranch的远程状态(实际上是:myRemote/myBranch)已被本地获取,然后放在其顶部。实际上不是HEAD,而是临时存在的FETCH_HEAD,专门用于此目的。

紧接着,git pull执行合并过程,如果允许且可能的话,通常会结束为快进更新操作,否则会进行常规合并并解决冲突。

为什么当我只执行git pull时,Git不提供这些反馈?

因为在没有参数的情况下执行git pull时,只能有一个获取的refspec,其中源和目标都是已知的并且是隐式的:您更新当前分支,因此在这里没有额外的精确说明是必要的。

您可能还希望使用git branch -vva来获取远程分支的名称。

英文:

First of all, these messages are given to you by the "fetch" part of a Git pull. You would get the same if you were using git fetch.

When you do:

git pull myRemote myBranch

… you don't actually fetch a distant myRemote onto a local myBranch.

myRemote is the name of remote repository and myBranch is the name of the remote branch you want to fetch back from there. The latter parameter is actually a refspec, which allows you to specify a source (distant) reference associated to an optional local homolog.

You may also use a wildcard * and/or specify multiple refspecs separated by spaces, which enables you to fetch multiple references in one shot, hence the explicit message which tells you exactly what happens for each of them.

For example:

git fetch origin master:my_cutty_local_master

… will fetch everything that actually regards origin/master, then create a local branch on top of it named my_cutty_local_master.

So what Git told you here is that the remote state of myBranch on server myRemote (that actually is: myRemote/myBranch) was locally fetched, then HEAD placed on top of it. Well actually not HEAD, but FETCH_HEAD which exists temporary for this sole purpose.

Just after that, git pull performs a merge process, which usually ends up in a fast forward update operation if allowed and possible, otherwise a regular merge with conflict resolving.

> Why does git not give this feedback if I do just git pull?

Because when doing git pull without arguments, there can be only one fetched refspec, where both source and destination are known and implicit: you update your current branch, so there's no need for extra precisions here.

You probably also want to use git branch -vva to get the names of remote branches too.

huangapple
  • 本文由 发表于 2023年3月7日 06:27:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75656418.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定