LoginSignup
1
0

More than 3 years have passed since last update.

同一端末で、複数のGitHubアカウントを使い分ける

Last updated at Posted at 2019-06-12

アカウント毎に公開鍵と秘密鍵を設定、それぞれid_rsa の名前を特定できるようにする

vi ~/.ssh/config

Host mygit
  HostName github.com
  User git
  Port 22
  IdentityFile ~/.ssh/id_rsa_local    →ここを変更する
  TCPKeepAlive yes
  IdentitiesOnly yes
Host othergit
  HostName github.com
  User git
  Port 22
  IdentityFile ~/.ssh/id_rsa_other    →ここを変更する
  TCPKeepAlive yes
  IdentitiesOnly yes

git cloneの際に一部変更する

localアカウントの場合

git clone git@github.com:hogehoge/fugafuga.git

git clone mygit:hogehoge/fugafuga.git

otherアカウントの場合

git clone git@github.com:mofumofu/ugauga.git

git clone othergit:mofumofu/ugauga.git

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0