Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

How do I `git checkout` a pull request?

Nathaniel Nutter edited this page Apr 1, 2015 · 3 revisions

You can checkout a single pull request reference by doing,

# replace $PR with the pull request number
git fetch origin +refs/pull/$PR/merge
git checkout FETCH_HEAD

If you want to fetch them all,

git fetch origin +refs/pull/*/merge:refs/remotes/origin/pr/*

For which you can then checkout the pull request by doing,

# replace $PR with the pull request number
git checkout origin/pr/$PR

If you want to automatically fetch pull requests you can add it to your repo's config,

git config --add remote.origin.fetch +refs/pull/*/merge:refs/remotes/origin/pr/*/merge
git fetch