仍是在转我笔记上的内容, 也算备份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上不会有小绿点, 我刚开始不知道, 可是能提交上去, 后天从新搞了一次才正常