11

I forked a project on github, since then the original owner made changes to it. How do I pull down those changes and merge them into my fork?

Thanks!

fancy
  • 48,619
  • 62
  • 153
  • 231

1 Answers1

16

First set up a remote for the upstream repository, if you haven't already:

git remote add upstream git://github.com/...

Then fetch the remote contents and merge from it (assuming you're on the corresponding master branch of your fork):

git fetch
git merge upstream/master
Will Vousden
  • 32,488
  • 9
  • 84
  • 95
  • You rarely want to work in the upstream's master. Unless you need it, I would skip the u-master creation. – Adam Dymitruk Jan 18 '12 at 00:13
  • @AdamDymitruk: True. I don't think I've actually used it with GitHub in fact; I use it mostly when I have an upstream "template" repo of my own that I've "forked" into a number of child repos, from which I might want to make changes to the upstream template. – Will Vousden Jan 18 '12 at 00:19
  • what does this mean? fatal: 'upstream' does not point to a commit – fancy Jan 18 '12 at 00:23
  • for some reason I had to pull it down, not just fetch... then it worked, thanks Will! – fancy Jan 18 '12 at 00:26
  • 7
    Because 'upstream' was not my default remote, this is what worked for me (which I guess is compressing the fetch and merge steps given above): `git pull upstream master` – sdesciencelover Dec 10 '12 at 15:28
  • "fatal: 'upstream/master' does not point to a commit" This doesn't work. – ABCD Mar 29 '19 at 00:00
  • I get the following error when I try to follow the instructions above `merge: upstream/master - not something we can merge` BTW, I should add that the upstream is the parent of the parent. i.e. the parent of my fork is already forked from the repo I'm trying to merge into my repo – Aswath Mar 25 '22 at 07:20