往github上push源碼出錯:! [rejected]... error: failed to push some ref to 'https://...'

在往github上push代碼時,步驟:
(1) git init
(2) git add .
(3) git commit -m “first commit” (“git commit -m “提交信息””)
(4) git remote add origin https://github.com/2281123066/doc2vec.git
(5) git push -u origin master

在第(5)步時出錯:
在這裏插入圖片描述
出現錯誤的主要原因是github中的README.md文件不在本地代碼目錄中。
可以通過如下命令進行代碼合併【注:pull=fetch+merge】
git pull --rebase origin master
在這裏插入圖片描述
執行上面代碼後可以看到本地代碼庫中多了README.md文件,
在這裏插入圖片描述
此時再執行語句 git push -u origin master即可完成代碼上傳到github。
在這裏插入圖片描述

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