仍是在轉我筆記上的內容, 也算備份git
參考(https://segmentfault.com/a/1190000002994742)
能夠對比着看, 我記得參考裏面有個點沒有說詳細, 我把本身的流程記下來了,但願對你們有用github
上一份工做要用gitlab, 折騰了好長時間才能同時用github
和gitlab
, 下面是我使用的詳細流程, 注意若是比較在乎github的小綠點的話要把github設置爲global
segmentfault
ssh-keygen -t rsa -C "註冊的gitlab郵箱"
提示要輸入名稱, 無論, 一路回車, 也不要設置密碼ssh
ssh-keygen -t rsa -C "註冊的github郵箱"
此次名稱輸入id_rsa_github
, 路徑保存在/home/ql/.ssh/
下面gitlab
在~/.ssh
路徑下分別有spa
分別讀取id_rsa
和id_rsa_github
code
cat id_rsa.pub # gitlab的祕鑰
cat id_rsa_github.pub #github的祕鑰
把內容分別複製到gitlab和githubit
在~/.ssh
下添加config配置文件email
ql@ql:~/.ssh$ ls config id_rsa id_rsa_github id_rsa_github.pub id_rsa.pub known_hosts ql@ql:~/.ssh$
config內容配置
# gitlab Host gitlab HostName gitlab.com IdentityFile ~/.ssh/id_rsa # github Host github HostName github.com IdentityFile ~/.ssh/id_rsa_github
~/workspace$ git config --global user.name "用戶名" ~/workspace$ git config --global user.email "註冊郵箱" ~/workspace$
rm -rf .git
刪掉~/github$ git config --local user.name "github用戶名" ~/github$ ~/github$ git config --local user.email "註冊郵箱" ~/github$
注意: 若是把github設置爲local
的話, 提交代碼github上不會有小綠點, 我剛開始不知道, 可是能提交上去, 後天從新搞了一次才正常