默認(rèn)情況
已經(jīng)配置好一個(gè)全局的賬號(hào)
在此基礎(chǔ)上搭建github的個(gè)人賬號(hào)
步驟
新建一個(gè)ssh key,保存在id_rsa_jacobma
中
$ ssh-keygen -t rsa -C 934273746@qq.com
$ Enter file in which to save the key (/Users/mayao02/.ssh/id_rsa): /Users/mayao02/.ssh/id_rsa_jacobma
$ Enter passphrase (empty for no passphrase):
$ Enter same passphrase again:
成功后,顯示key
值并復(fù)制到github
$ cat ~/.ssh/id_rsa_jacobma.pub
測(cè)試是否能連接到遠(yuǎn)程倉(cāng)庫(kù)
$ ssh -T git@github.com
若未成功俊马,則把該key
加到ssh agent
$ ssh-add ~/.ssh/id_rsa_jacobma
配置config
$ vi .ssh/config
添加以下內(nèi)容
Host jacobma
HostName github.com
IdentityFile ~/.ssh/id_rsa_jacobma
拉下github的項(xiàng)目后丽旅,需要配置此項(xiàng)目的賬號(hào),否則會(huì)以全局的賬號(hào)名來(lái)提交
$ git config user.name "JacobMa1996"
$ git config user.email "934273746@qq.com"
END