1.does not appear to be a git repository
[root@myhost Linux-Note]# git push -u ogrin master
报错信息:
fatal: 'ogrin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
错误分析:
这个错误是因为你输入了错误的仓库名
使用git remote -v 查看远程仓库的名
[root@myhost Linux-Note]# git remote -v
origin https://github.com/ck784101777/Linux-Note.git (fetch)
origin https://github.com/ck784101777/Linux-Note.git (push)
这里origin是我的远程库名,再看看之前的命令:git push -u ogrin master 。 发现我的origin打成了ogrin,所以报错
解决步骤:
1)查看远程库名 git remote -v
2)核对库名,再输入上传命令
2.fatal: remote origin already exists.
[root@myhost Linux-Note]# git remote add origin https://github.com/ck784101777/Linux-Note.git
报错信息:
fatal: remote origin already exists
错误分析:
origin仓库已存在,所以我们需要更换一个仓库名,也可以删除远程仓库,再上传
解决步骤1:
1)查看远程仓库 git remote -v
2)上传时更换仓库名 git remote add origin2 https://github.com/ck784101777/Linux-Note.git
解决步骤2:
1)查看远程仓库 git remote -v
2)删除仓库 git remote rm origin
3)上传 git remote add origin https://github.com/ck784101777/Linux-Note.git
3.src refspec master does not match any.
[root@myhost Linux-Note]# git push -u origin master
报错信息:
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/ck784101777/Linux-Note.git'
报错分析:
上传失败的原因是系统没有匹配到需要提交的文件(本地仓库是空的),也就是说你并没有 git commit ,如下
[root@myhost Linux-Note]# git status
# On branch master
nothing to commit, working directory clean
解决步骤:
1)查看状态 git status
2)提交到本地仓库 git commit -m 'xx'
3)上传 git push -u origin master