如何連接多個GitHub帳戶

  1. 產生一個新的 SSH key
$cd ~/.ssh 
$ssh-keygen -t rsa -C "userName@address"
github.com -> Settings -> SSH and GPG Keys -> New SSH Keys
$pbcopy < ~/.ssh/id_rsa_XXX.pub // copy the file content(Mac)
$vim ~/.ssh/config在 config file 裏輸入:
Host github-new
HostName github.com
User loginUserName
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_XXX
$ssh -T git@github-new
Hi loginUserName! You’ve successfully authenticated, but GitHub does not provide shell access.
如果有問題需要debug可以加v.
$ssh -vT git@github-new
$git remote add origin git@github-new:loginUserName/repoName.git
設定這個Repository的User資料
$git config user.email "xxx@xxx.com"
$git config user.name "loginUserName"

 by the author.

--

--

A Programmer, Data Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store