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.添加远程仓库

[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 '13.229.188.59' to the list of known hosts.
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:wcp-one/plugin.git'
2步解决

1.在/etc/hosts下添加

13.229.188.59 github.com

2.添加上传信息参上


你可能感兴趣的:(git)