Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

アカウント毎に公開鍵と秘密鍵を設定、それぞれ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

参考

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away