To checkout a PR from another repo. Eg you fork a repo you don’t own, or are not a member of. Someone else makes a PR to the original repo and you want to evaluate it locally in your fork.
Add a remote upstream repository
git remote add UPSTREAM [email protected]/USERNAME:REPONAME
Check that it has been added - optional
git remote -v
Fetch all the branches from that repository
git fetch UPSTREAM
Will list all the available branches
Checkout the one you want to evaluate into its own branch locally
git checkout -b UPSTREAM/BRANCHNAME
Originally from stackoverflow
Example
git remote add upstream [email protected]/bbc:react-transcript-editor
git remote -v
git fetch upstream
git checkout -b upstream/timed-text-editor-fixes