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.
The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content. Merging remote upstream changes into your local repository is a common task in Git-based collaboration work flows.
The git fetch command downloads commits, files, and refs from a remote repository into your local repo. Fetching is what you do when you want to see what everybody else has been working on.
git fetch is the command that tells your local git to retrieve the latest meta-data info from the original (yet doesn't do any file transferring. It's more like just checking to see if there are any changes available). git pull on the other hand does that AND brings (copy) those changes from the remote repository.
Go to your fork, click on Fetch upstream , and then click on Fetch and merge to directly sync your fork with its parent repo. You may also click on the Compare button to compare the changes before merging.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With