案件が複数、githubアカウントも複数で困っている方向け
1、~/.ssh/configファイルを作成する
configファイルを下記の様に記載。
※Hostや秘密鍵の部分は自分の環境で合わせてください。
~/.ssh/config
#プロジェクトAはgithubアカウントA
Host projectA
HostName github.com
User git
Port 22
#↓名前は超適当
IdentityFile ~/.ssh/github_a_rsa
TCPKeepAlive yes
IdentitiesOnly yes
#プロジェクトBはgithubアカウントB
Host projectB
HostName github.com
User git
Port 22
#↓名前は超適当
IdentityFile ~/.ssh/github_b_rsa
TCPKeepAlive yes
IdentitiesOnly yes
2、各プロジェクトのリモートリポジトリURLをメモする。
git@github.com:AccountA/projectA.git
git@github.com:AccountB/projectB.git
3、各プロジェクトの.gitファイルと同じ階層で下記コマンドをそれぞれ実施
ターミナル上での操作
#プロジェクトAの.gitと同階層で実行
$git remote add origin git@projectA:AccountA/projectA.git
#プロジェクトBの.gitと同階層で実行
$git remote add origin git@projectB:AccountB/projectB.git
これで無限にプロジェクト設定できますね。
後は、pullなりpushなりお好きにどうぞm(__)m