Skip to content

Support checkout for PRs whose head matches an unrelated local branch #233

@mislav

Description

@mislav

Suppose two different people use the GitHub web flow to submit patches to the same repository:

  • PR #1 with head user1:patch-1
  • PR #2 with head user2:patch-1

The default branch name for web flow is patch-1 and a lot of people leave that unchanged.

We want to support both gh pr checkout 1 and gh pr checkout 2 used interchangeably, but right now the 2nd operation will fail because after the 1st operation, a local patch-1 branch already exists, but is associated with another PR and trying to fast-forward it to the latest commits in user2:patch-1 will fail on the git level due to unrelated histories.

Proposed solution:

gh pr checkout 1 # Works like before,
gh pr checkout 2 # Issues warning on stderr that `patch-1` already exists and
                 # names the new branch with a unique name such as `user2-patch-1`.

https://github.slack.com/archives/CLLG3RMAR/p1579201119275200

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-prrelating to the gh pr commandpriority-2Affects more than a few users but doesn't prevent core functions

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions