Search code examples
gitpull

Git pull response message meaning


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..)


Solution

  • 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.