0

So I'm currently reviewing a pull request from an upstream repo that I forked, and created a local branch to fetch the pull request via git fetch upstream pull/869/head:readme. However, there have been some recent commits made to that pull request since I created the branch. How do I update the pull request branch to incorporate the new commits? Pull requests aren't visible in the same way that would allow me to otherwise do a git fetch upstream and git merge upstream/master

  • Possible duplicate of [How do I force "git pull" to overwrite local files?](https://stackoverflow.com/questions/1125968/how-do-i-force-git-pull-to-overwrite-local-files) – jhpratt Aug 02 '17 at 04:33
  • Is there a way to directly access pull request branches? I see upstream/master or upstream/staging, not the pull request branches on GitHub. – Vignesh Sankaran Aug 02 '17 at 04:40

1 Answers1

1

Try:

git config --add remote.upstream.fetch "+refs/pull/*/head:refs/remotes/upstream/pr/*"

See more at "prm.md". The default refspec (+refs/heads/*:refs/remotes/upstream/*) does not fetch pull request

Then a fetch upstream would allow you to see

upstream/pr/189

And you can rebase (not merge) your own branch of top of it.

git rebase upstream/pr/189
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This results in a `fetch` refspec that looks like `fetch = fetch = +refs/pull/*/head:refs/remotes/upstream/pr/*` – Vignesh Sankaran Aug 02 '17 at 06:13
  • @VigneshSankaran sorry, I forgot the `--add` option, in order to keep the default refspec. Restore it with `git config --add remote.upstream.fetch "fetch = +refs/heads/*:refs/remotes/upstream/*"`. – VonC Aug 02 '17 at 06:28