git免密登录

查看~/.ssh目录下是否生成秘钥,有的话删除

1.重新生成秘钥

[root@db02 ~/.ssh]# ssh-keygen -t rsa -C "[email protected]"  

2.查看秘钥并且复制

[root@db02 ~/.ssh]# cat id_rsa.pub  

3.打开github或者你公司的git的网页,在Settings–>SSH keys中点击New SSH Keys把复制的秘钥粘贴并保存退出

4.找一目录执行

git init  #初始化git目录

5.添加远程仓库

[html] view plain copy
[root@db02 /test]# git remote add origin [email protected]:wcp-one/plugin.git 

6.添加用户信息

[root@db02 /test/plugin]# git config --global user.name "wcp-one"  
[root@db02 /test/plugin]# git config --global user.email "[email protected]"  

7.添加上传分支

[root@db02 /test/plugin]# git add open-falcon.sh   
[root@db02 /test/plugin]# git commit -m "init files"  

8.上传

[root@db02 /test/plugin]# git push -u origin master  

成功免密上传


报错及解决

[root@db02 /test/plugin]# git push origin master  
Warning: Permanently added the RSA host key for IP address '<span style="color:#ff6666;">13.229.188.59</span>' to the list of known hosts.  
<span style="color:#ff6666;">error</span>: src refspec master does not match any.  
<span style="color:#ff6666;">error</span>: failed to push some refs to '[email protected]:wcp-one/plugin.git'  

1.在/etc/hosts下添加

13.229.188.59 github.com

2.添加上传信息参上


猜你喜欢

转载自blog.csdn.net/wanchaopeng/article/details/80824508