How to fetch Github pull request as local branch

Github pull requests are the mechanism by which contributors submit code for review and subsequent merging to a Github branch. It can sometimes be useful to grab a pull request as a branch in your local repository. This can be useful for example to diff with one of your local branches or to merge with one of your local branches.

To fetch a Github pull request, note down its number XYZ. Use this command to fetch it to a new local branch:

$ git fetch origin pull/XYZ/head:new_local_branchname

The pull request is now available locally as the branch new_local_branchname.

Reference: https://help.github.com/en/articles/checking-out-pull-requests-locally

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.