Skip to content

gh repo fork adds remote using https protocol even if repository was cloned through ssh #1056

Description

@thomaseizinger

Describe the bug

Cloning a repository through ssh and forking it adds the fork using the https protocol.

❯ gh --version
gh version 0.9.0 (2020-05-27)
https://github.com/cli/cli/releases/tag/v0.9.0

Steps to reproduce the behavior

  1. Make a temp directory: cd $(mktemp -d)
  2. Clone a repository via ssh: gh repo clone [email protected]:cli/cli.git
  3. Navigate into the repository: cd cli
  4. Fork the repository: gh repo fork --remote=true
  5. List all remotes: git remote -v

Expected vs actual behavior

Expected behaviour

The new fork uses the ssh protocol because the repo was originally cloned through that.

Actual behaviour

The fork was added using the https protocol:

❯ git remote -v
origin	https://github.com/thomaseizinger/cli.git (fetch)
origin	https://github.com/thomaseizinger/cli.git (push)
upstream	[email protected]:cli/cli.git (fetch)
upstream	[email protected]:cli/cli.git (push)

Activity

  1. changed the title [-]`gh repo fork` adds remote using `https` protocol[/-] [+]`gh repo fork` adds remote using `https` protocol even if repository was cloned through `ssh`[/+] on May 31, 2020
  2. vilmibm commented on Jun 1, 2020

    @vilmibm
    Contributor

    You can work around this by running gh config set git_protocol ssh between the clone and the fork, but I think it would be nice when forking to match whatever protocol is in use in the parent's existing remote. I remember we discussed this kind of improvement internally but looking now I don't see any issues about it so we can use this one; thanks for opening it.

  3. AliabbasMerchant commented on Jun 1, 2020

    @AliabbasMerchant
    Contributor

    (@vilmibm It was #736)
    I can take this up

  4. Hultner commented on Jun 1, 2020

    @Hultner

    Seems like it uses https when creating repos as well, I always use ssh for git but can't find any way to teach gh that.

  5. AliabbasMerchant commented on Jun 2, 2020

    @AliabbasMerchant
    Contributor

    @Hultner use this: gh config set git_protocol ssh

  6. added
    priority-3Affects a small number of users or is largely cosmetic
    on Sep 30, 2020
  7. self-assigned this
    on Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpriority-3Affects a small number of users or is largely cosmetic

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions