I’ve forked a repository and need to review a PR from the original upstream repo.
Normally, I’d just fetch branches manually, but I’ve heard there might be a simpler way to handle this using a tool or command. I’m particularly interested in checking out the upstream PR directly into my local environment.
Is there an efficient way to do this? If so, what’s the best approach?
I’d appreciate any guidance or instructions on how to make this process easier!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey there!
There’s actually a fairly easy way to check out a pull request from the upstream repo using the GitHub CLI (
gh
).If you don’t already have it installed, you can grab it from here.
Once you’ve got
gh
set up, here’s what you need to do:First, make sure you’ve added the upstream repo as a remote (if you haven’t already):
Next, use this command to check out the PR locally:
Replace
PR_NUMBER
with the actual pull request number andupstream-repo
with the correct repo name (e.g.,original/repo
).After that, you’ll be on the PR branch, and you can review or work on the code just like any other branch.
If you don’t want to install
gh
, you could still do this the old-school way by fetching the PR branch manually, but trust me, the CLI makes it way easier!Hope this helps! Let me know if you run into any issues! 👍
- Bobby