1

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.

Community
  • 1
  • 1
Sailesh Sriram
  • 144
  • 2
  • 17

2 Answers2

0

Short answer NO. You have to add the upstream repo as another remote. You can name it upstream, of course. and then run git pull upstream master

You can add the remote like this:

git remote add upstream <url-of-upstream-repo>
TheGeorgeous
  • 3,927
  • 2
  • 20
  • 33
0

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:

fork

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.

Community
  • 1
  • 1
Karup
  • 2,024
  • 3
  • 22
  • 48