git fetch vs. git fetch origin master have different effects on tracking branch

If your branch has an associated remote tracking branch that means its configuration is like:

git config branch.[branch-name].remote [remote-name]
git config branch.[branch-name].merge [remote-master]

The key part of git fetch which explain the difference between the two commands is:

<refspec>

The format of a <refspec> parameter is an optional plus +, followed by the source ref <src>, followed by a colon :, followed by the destination ref <dst>.
The remote ref that matches <src> is fetched, and if <dst> is not empty string, the local ref that matches it is fast-forwarded using <src>.

Let me repeat it:

if <dst> is not empty string, the local ref that matches it is fast-forwarded using <src>.
Knowing that:

  • git fetch is equivalent to git fetch origin master:master (from the default value of your branch config), so it will update the remote tracking branch: the destination of the refspec is specified for you.

  • git fetch origin master is equivalent to “git fetch origin master:“, not to “git fetch origin master:master“; it stores fetched value of ‘master‘ branch (of remote ‘origin‘) in FETCH_HEAD, and not in ‘master‘ branch or remote-tracking ‘remotes/origin/master‘ branch (from Jakub NarÄ™bski’s answer)
    In other words, you didn’t specify the destination of your refspec

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)