Closed6

複数アカウントで ghq を使いたい

K SAEKIK SAEKI

ghq で自分のプライベートリポジトリをクローンしようとしたらエラーになった。

ghq get -p koyasaeki/****

     clone ssh://git@github.com/koyasaeki/****-> /****/koyasaeki/****
       git clone --recursive ssh://git@github.com/koyasaeki/****
 /****/koyasaeki/****
Cloning into '/Users/saeki/ghq/github.com/koyasaeki/****'...
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
     error failed to get "koyasaeki/****": /opt/homebrew/bin/git: exit status 128
K SAEKIK SAEKI

GitHub のアカウントが複数あり、正しい方を参照できていないよう。

K SAEKIK SAEKI

鍵作って GitHub に登録する。

ssh-keygen -t ed25519

ファイル名は既にあるやつと被らないように id_second_ed25519 みたいにしておく。

K SAEKIK SAEKI

~/.ssh/configHost が被らないように登録する。
今回は github-second とした。

Host github-second
  HostName github.com
  IdentityFile ~/.ssh/id_second_ed25519

これでアクセスする。

ssh -T github-second

Hi koyasaeki! You've successfully authenticated, but GitHub does not provide shell access.
K SAEKIK SAEKI

あとは普通に(?) ghq を使う。

ghq get git@github-second:koyasaeki/****.git

これで別アカウントのプライベートリポジトリが取得できる。
-p オプションで取りたいが思いつかなかった。)

このスクラップは3ヶ月前にクローズされました