1

I'm struggling with git/SSH multiple identities (one personal/work and one dedicated to yet another company)

I've managed to somehow create a virtual local "routing" thanks to https://simonbasle.github.io/2017/10/git-identities-and-ssh/, which selects the right SSH key depending on where the local repo is located on the disk. That's a first good step.

But I'm struggling to adapt my "gh" commands:

gh repo create REPO_NAME \
--template USER_NAME/TEMPLATE_NAME \
--private \
--clone

Doing this somehow successfully creates the REPO_NAME repository in the USER_NAME account, but then it fails at the "clone" step, with ERROR: Repository not found..

I believe that's because gh doesn't use the right SSH key, but I don't understand how to specify which one to choose from.

torek
  • 448,244
  • 59
  • 642
  • 775
Vadorequest
  • 16,593
  • 24
  • 118
  • 215
  • I'm no expert on `gh` but my understanding is that when it creates a repository, it uses the GitHub v3 API via https (only), even if it later uses ssh to clone the created repository. You might be best off using `gh` to create it, and then `git clone` with the adjusted URL as in the article you referenced. That is, your `gh repo create` *is not* using ssh. By doing `git clone` yourself, rather than with `gh`, you can control the URL you supply. – torek Dec 04 '22 at 08:24
  • 1
    Still, there may be a way to get the `--clone` option to work. I adjusted your tags to reach `gh` experts. – torek Dec 04 '22 at 08:28
  • I just found https://stackoverflow.com/questions/74644191/how-do-i-tell-the-github-cli-to-use-a-specific-ssh-key which seems to say "this isn't yet supported". – Vadorequest Dec 04 '22 at 10:17

0 Answers0