Using multiple GitHub accounts on one computer
在一台電腦使用多個GitHub帳號
-
產生 SSH Key
ssh-keygen -t rsa -C "your_email@example.com" -f ~/.ssh/your_key
-
複製公鑰至 GitHub
pbcopy < ~/.ssh/your_key.pub
將內容貼到 GitHub 的 SSH Keys 設定。
-
啟動 SSH-Agent 並加入密鑰
eval "$(ssh-agent -s)" ssh-add -K ~/.ssh/your_key
-
設定 SSH config
touch ~/.ssh/config
編輯
~/.ssh/config
:Host github-work HostName github.com User git IdentityFile ~/.ssh/your_key
-
測試連線
ssh -T git@github.com