解決git push 出現錯誤 error: failed to push some refs to '[email protected]:xxxxx'

使用github時,本地git push命令出現錯誤 error: failed to push some refs to '[email protected]:xxxxx'

 

  • 出錯現象:

 

  • 原因:

git push 時出現這個錯誤的主要原因是在github中的README.md文件不在本地代碼目錄中

 

  • 解決方法:

先把GitHub倉庫的文件下載到本地代碼倉庫,且在本地代碼倉庫進行代碼合併,然後再上傳到GitHub倉庫。

1、可以通過如下命令進行代碼合併【注:pull=fetch+merge]

git pull --rebase origin master

執行完 git pull 命令後在本地git代碼目錄下可以看到README.md文件

一些命令註釋:

2、上傳本地代碼到遠程倉庫GitHub

如下命令上傳本地代碼到遠程倉庫,第一次上傳代碼到倉庫加 -u,往後-u可以省略爲:git push origin master

git push -u origin master

成功上傳本地代碼到遠程倉庫GitHub。

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章