Skip to content

Checkout source branch from remote fails with duplicate remote entries #1559

@jeremyfiel

Description

@jeremyfiel

Describe the bug
When using the checkout branch button on the pull request:
If the remote entry exists in git config, the extension attempts to add a new remote to check out the source branch from the remote repository but it creates a conflicting remote entry where the branch name matches two remote tracking branches and it's unable to check out the source branch.

{
"exitCode": 128,
"gitCommand": "checkout",
"stderr":  "hint if you meant to check out a remote tracking branch on, e.g. 'origin',  you can do so by fully qualifying the name with --track option. if you'd like to always have checkouts of an ambiguous name prefer one remote consider setting checkout.defaultRemote=origin in your config. fatal: Branch name matched multiple remote (2) tracking branches"

To Reproduce
Using the forking strategy with two separate repositories:
Configure git config with the origin repository and a remote repository.

Open a pr with a branch from the remote repository as the source and the destination as the origin repository.

Open the new PR in the extension from the origin repository and click checkout source branch.

Expected behavior
There should be some validation to verify if an existing remote exists with the value as either https or SSH with the same repository name and utilize that remote entry rather than creating a new one

Screenshots
If applicable, add screenshots to help explain your problem.

Environment and Version (please complete the following information):

  • Atlassian Plugin Version (x.x.x)
  • Visual Studio Code Version (x.x.x)
  • Is this a local or cloud environment? (Cloud | Local)
  • If Cloud, Browser (chrome, safari)
  • If Local, OS (macOS, windows, linux)

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions