如何解決failed to push some refs to git

git push -u origin mastergit

報錯 To https://gitee.com/sunki/youshang_web.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/*****'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.github

此時嘗試下面的命令把當前分支代碼上傳到master分支上。web

$ git push -u origin master
但依然沒能解決問題fetch

出現錯誤的主要緣由是github中的README.md文件不在本地代碼目錄中;blog

能夠經過以下命令進行代碼合併【注:pull=fetch+merge]rem

git pull --rebase origin masterit

執行上面代碼後能夠看到本地代碼庫中多了README.md文件ast

 

此時再執行語句 git push -u origin master便可完成代碼上傳到gitsed

相關文章
相關標籤/搜索