Skip to content

Add command to checkout a pull request branch #20

@jcansdale

Description

@jcansdale

@ethomson has some tips on how to checkout PRs here:
http://edwardthomson.com/blog/advent_day_5_review_pull_requests_locally.html

After some initial configuration, this allows checking out a PR like this:

git fetch pr
git checkout pr/1234

It would be nice if git pr supported something similar. For example:

git pr checkout 1234

This would locate the pull request branch and checkout that (rather than the pull request reference). The advantage of using the branch rather than the reference would be the user could push to the branch if they're the repository owner/collaborator.

If the pull request was submitted be an external contributor, the contributor/remote name would need to be specified:

git pr checkout 1234 --remote {contributor}

I've been wondering what a sensible format for the local branch would be. It could contain information about the PR number, owner and/or branch name:

pr/1234/contributor/branch-name
pr/1234/branch-name
branch-name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions