Today, I got a task to test the PR https://github.com/GreatDevelopers/TCC/pull/2
Steps to test the PR in separate branch before merge
1. Create and switch to new branch
$git checkout -b <new_branch_name> <remote_name/existing_branch_name>
Here second parameter is optional. If not mentioned then it will create a new branch exact copy of current branch.
In second parameter you have to give two values remote_name and branch name existing in that remote.
If no remote name is mentioned then by default it will account remote_name=origin.
If I am having more than one remotes as shown below.
$ git remote -v
amisha https://github.com/amisha2016/TCC (fetch)
amisha https://github.com/amisha2016/TCC (push)
origin https://github.com/GreatDevelopers/TCC.git (fetch)
origin https://github.com/GreatDevelopers/TCC.git (push)
Now, I want to create a new branch exact copy of existing branch of remote amisha.
$git checkout -b new amisha/master
2. Pull the PR to the new branch
$git pull <remote_URL> <branch_name>
Here remote_URL is the URL of the repository who has opened/send that PR and branch_name is the name of branch where he has committed that changes. In the image the branch _name is HTML_files.
But in my case the situation was not that easy. Actually the person who has send that PR has deleted the fork of that repository.
Here branch name is unknown repository. So, the solution is below.
$git checkout master
$ git fetch -f origin pull/2/head:new
Second command means to fetch the changes from PR #ID(here ID is 2) to the newly created branch new. Remember this command won’t work if you are in the same branch where changes to be applied(here branch name is new). That is why I checkout to master branch initially.
My senior Mandeep Singh helped in it.
Now test the PR and enjoy while merging 😛