git添加远程库遇到的问题

把本地库所有内容推送到远程库上指令:

$ git push -u origin master


出现下面的错误提示:

error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:accompanyling/learngit.git'


我的解决方案:

删除当前key,然后重新生成key:

$ ssh-keygen -t rsa -C "[email protected]"

941a966412c9d42fca5c595a1b8646784a4fbd21
 

该命令行会在C:\Users\Administrator中生成.ssh文件夹。里面有id_rsa和id_rsa.pub文件。

复制id_rsa.pub文件里面的内容。

打开github设置key  将上面复制的内容粘贴在New SSHKey->key中

1ab56ac8e5d35498df8ea17bf36022ab6e80b11f

最后我的做法是把之前在本机上建立的版本库全部删掉,从新建立:

第一步,先创建空目录:

$ mkdir learngit
$ cd learngit
$ pwd

pwd命令会得到该目录的路径

第二步,通过git init命令把这个目录变成Git可以管理的工具

$ git init

第三步,添加文件到版本库也就是在learngit文件夹中

第四步,用命令git add +文件名,把文件添加到仓库

原文链接

猜你喜欢

转载自blog.csdn.net/weixin_40581617/article/details/81906719