Checkout Pull Requests from GitHub
GitHub give us an effective way to collaborate on development projects. Developers easily can participate on a project and contribute. The way to contribute is often called as the pull request workflow. When developers want to suggest some code change, they modify the code and can send code change which is called a pull request. Project maintainers, including you, can review the set of changes, discuss and merge those.
Usual way to review is by looking. However, sometimes you may want to run the modified code instead of just looking. How can you do it? Unfortunately, you cannot simply checkout and run it because it was not made by you. In order to checkout it, you need to specify a remote repository name and a branch name. Because there are many contributers, <user_name>
could be different for each pull request and could be a quite tedious task.
What is the better way? In fact, GitHub creates a special branch for each pull request. You can refer it as refs/pull/<pull_request_number>/head
. Thus, you can easily checkout it when you know the pull request number.
If you do this frequently, you probably will consider git aliases. Someone(https://gist.github.com/gnarf/5406589) already made those aliases, and you can just use it.
There are two aliases. pr
is to fetch the pull request branch and checkout. pr-clean
is to delete every fetched pull request branch.