0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

メモ:同一端末で複数のGitHubアカウントをレポ毎に別に使い分ける設定

Last updated at Posted at 2018-09-05

$ cd ~/.ssh
$ ls
id_rsa id_rsa.pub
既存のファイル名以外のファイル名を指定してSSH鍵生成
$ ssh-keygen -t rsa -C [メールアドレス] -f [ファイル名]

$ cat ~/.ssh/id_rsa_sub.pub | pbcopy

https://github.com/settings/ssh
「Add SSH Key」へ貼る

$ subl ~/.ssh/conifg
Host github.com
HostName github.com
User git
Port 22
IdentityFile ~/.ssh/id_rsa # メインのアカウント用SSH鍵ファイルへのパス
TCPKeepAlive yes
IdentitiesOnly yes
Host github.com.sub # github.com以外の名前
HostName github.com
User git
Port 22
IdentityFile ~/.ssh/id_rsa_sub # サブアカウント用SSH鍵ファイルへのパス
TCPKeepAlive yes
IdentitiesOnly yes

接続確認
$ ssh -T

利用するアカウント設定
$ cd Project
$ git config --local user.name "サブアカウント"
$ git config --local user.email "サブアカウントメールアドレス"

Remote repository設定
$ git clone git@github.com.サブアカウント:GHaccount/GHrepo.git
$ git remote add origin git.サブアカウント@github.com:GHaccount/GHrepo.git

source:
https://qiita.com/yamataku29/items/4744c9c70ad793c83b82
https://github.com/youkinjoh/TrainingWebSocket/wiki/%E5%90%8C%E4%B8%80%E7%AB%AF%E6%9C%AB%E3%81%A7%E3%80%81%E8%A4%87%E6%95%B0%E3%81%AEGitHub%E3%82%A2%E3%82%AB%E3%82%A6%E3%83%B3%E3%83%88%E3%82%92%E4%BD%BF%E3%81%84%E5%88%86%E3%81%91%E3%82%8B%E6%96%B9%E6%B3%95

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?