git上傳文件error:src refspec master does not match any

本地倉庫使用如下命令初始化:

$ git init

之后使用如下命令添加遠程庫:

$ git remote add origin git@github.com:hahah/ftpmanage.git

然后使用

$ git push -u origin master

出現(xiàn)如下錯誤:

error: src refspec master does not match any. error: failed to push some refs to 'git@github.com:hahaha/ftpmanage.git'

引起該錯誤的原因是,目錄中沒有文件,空目錄是不能提交上去的

解決方法:

touch README

git add README

git commit -m 'first commit'

最后執(zhí)行$ git push -u origin master

如果出現(xiàn)這個錯誤:Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

可能是暫存區(qū)沒有文件,通過git add操作可以添加到暫存區(qū)以便commit。

運行 $git add .成功把文件存到暫存區(qū)

接下來繼續(xù)運行$git commit -m 'first commit'將暫存區(qū)的代碼提交到本地倉庫

最后成功push到GitHub上面 $git push origin master

如果push中出現(xiàn)如下錯誤:: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

.這可能是是由于你的git地址采用了ssh方式,切換為https方式

在終端中輸入:

$ git remote set-url origin?https://github.com/YourUserName/YatouTest00123.git

然后再push一下

$git push -u origin master

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容