In the section Pulling in upstream changes on help.github's Forking a project it states:
Some time has passed, the upstream repo has changed and you want to update your fork before you submit a new patch. There are two ways to do this:
$ git fetch upstream master
$ git merge upstream/master
Why are they including master
in the fetch command? I've looked at the git help fetch
information but I'm not understanding what including master
does. Thanks.
That allows you to:
The git merge
will then try to merge that local version of the upstream master to your repo master branch.
So here, master is, for the fetch
command, a refspec.
<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>
.
If the optional plus+
is used, the local ref is updated even if it does not result in a fast-forward update.
Here, <dst>
is empty, so the matching local branch (your master) is updated.
Without master, that would give:
git fetch upstream
The above command copies all branches from the remote
refs/heads/
namespace and stores them to the localrefs/remotes/upstream/
namespace, unless thebranch.<name>.fetch
option is used to specify a non-default refspec.