From What is the difference between 'git pull' and 'git fetch'?,
If git pull
is a combination of git fetch
followed by a git merge
, can git pull upstream master
be used to fetch and merge the changes from the upstream in the clone of a forked repository.
As @VonC said in one of his answer -
You have to add the original repository (the one you forked) as a remote.
From the GitHub fork man page:
Once the clone is complete your repo will have a remote named “
origin
” that points to your fork on GitHub.
Don’t let the name confuse you, this does not point to the original repo you forked from. To help you keep track of that repo we will add another remote named “upstream”:
$ cd github-services
$ git remote add upstream git://github.com/pjhyett/github-services.git
$ git fetch upstream
# then: (like "git pull" which is fetch + merge)
$ git merge upstream/master master
# or, better, replay your local work on top of the fetched branch
# like a "git pull --rebase"
$ git rebase upstream/master
After fetching from the remote branch, you would still have to merge the commits.
Here what you can do is replace
$ git fetch upstream
with
$ git pull upstream master
since git pull
is essentially git fetch
+ git merge
as you said.