How to fetch code for reviewing a PR - Anjum219/Git-basics GitHub Wiki
For first time
Copy the HTTPS/SSH link from the remote repository you want to fetch. At your local, write the following command-
git remote add <remote_name> <HTTPS/SSH link>
This adds the remote repository in the local branch you are in. Now fetch the code from the remote-
git fetch <remote_name>
Remember, you don't want to merge the code of the PR with your local branch. git fetch brings the code to you but don't merges with you. So, don't do "git pull <remote_name> <branch_name>". Now to run the code and work with it locally, do
git checkout -t <remote_name>/<branch_name>
This will create a branch at your local with the same name as the name of the remote's branch.
For future working on that remote
git fetch <remote_name> <branch_name>
git checkout <branch_name>
git merge <remote_name>/<branch_name> --ff-only
or if you had made your own changes to that branch, instead of using merge, use-
git reset --hard <remote_name>/<branch_name>