1

I forked project created branch made some changes on it and created pull request. Repo owner added some minor changes to master. I need to pull this changes from original project master to my fork branch.

I tried

git fetch origin

but nothing happens.

BT101
  • 3,666
  • 10
  • 41
  • 90
  • 1
    Possible duplicate of [How do I update a GitHub forked repository?](https://stackoverflow.com/questions/7244321/how-do-i-update-a-github-forked-repository) – phd Jun 30 '19 at 11:16
  • https://stackoverflow.com/search?q=%5Bgit%5D+update+forked+repository – phd Jun 30 '19 at 11:16

1 Answers1

3

If you try git remote -v you'll notice that origin points to your fork and not to the original repository.

In order to get changes from the original one, you should add a new remote:

git remote add upstream <URL>

and then pull changes from that remote:

git fetch upstream

Now if you show the remotes again, you should have something like:

$ git remote -v
origin    https://github.com/... (fetch)
origin    https://github.com/... (push)
upstream  https://github.com/... (fetch)
upstream  https://github.com/... (push)

Note that the name upstream is not special, you can set it to whatever you want.

Maroun
  • 94,125
  • 30
  • 188
  • 241
  • Ok so I have `remotes/upstream/master` so next step to get changes from it into `myBranch` is to ...? – BT101 Jun 30 '19 at 10:43
  • Well, now you have the updated branch, you can `git rebase upstream/master` (or a simple merge, or whatever you want). – Maroun Jun 30 '19 at 10:45