Skip to content

gh repo clone specify upstream fetch args #2557

@cdce8p

Description

@cdce8p

Describe the feature or problem you’d like to solve

I really like that gh repo clone automatically adds the upstream repository as a remote. However what keeps my from using it is that I don't have any option to specify which parts of the upstream repo I want to fetch. The command just assumes it's everything. Especially for large projects this might not always be the case.

gh repo clone already allows the user to specify additional <gitflags>.
However they will only apply to git clone not git remote add -f upstream.

Proposed solution

Add the ability to specify the -t <branch> flag for git remote add (doc). Since git clone (doc) doesn't use this flag, it should be possible to filter it from <gitflags> and pass it along to git remote add.

How will it benefit CLI and its users?

User will be able to decide for themselves which parts of the upstream remote they what to fetch when using gh repo clone.

Additional context

git remote add supports a few other flags as well: --tags, --no-tags, -m <master>. --tags and -m are exclusive to git remote add so those could be passed as well, although I don't know how common that would be. --no-tags is a bit more complicated, since both commands support this flag. Therefore I would refrain from adding from git remote add to make clear it belongs to git clone. In addition the default behavior for git remote add -f is to only fetch tags associated with the branches that are being fetched. Those in turn would already be limited by -t <branch>.

There is a point to be made to only add support for -t <branch>. Since this is probably by far the most common used option, doing so would cover that use case and doesn't introduce additional ambiguity which --no-tags would probably do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions