Skip to content

Allow for setting default upstream of main branch when gh repo clone #10912

@jwlodek

Description

@jwlodek

Describe the feature or problem you’d like to solve

Currently, if I run gh repo clone my_repo, wheren my_repo is a fork under my github account of another repository, I get two remotes set up, an upstream and an origin, with the default branch (typically main) having its upstream set to origin/main.

For my typical workflow, it would be preferable to have the upstream of the main branch be upstream/main (or whatever name is passed with -u, since what I typically will do is:

  1. Checkout the main branch
  2. Pull changes from upstream
  3. Make a new feature branch
  4. Push to my fork.

So currently, after a gh repo clone my_repo, I always run git branch --set-upstream-to upstream/main. I'd prefer if this could be done in the original clone command.

Proposed solution

An additional optional boolean flag to gh repo clone, that will set the upstream of the main branch to the upstream remote, if set (if cloning a repo that is a fork in the user's namespace).

If the flag is set, I'd like for the original clone to be made from the upstream remote, rather than from my fork.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions