$ git push -u origin master 推送到遠端庫出錯
1、錯誤描述:
出錯場景描述:
github上建立遠端倉庫的時候選擇新增README.md檔案,
git bash連線遠端庫,然後執行push操作,出現下面的問題
$ git push -u origin master
To github.com:XXXX/DesignPatterns.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to '[email protected]:XXXX/DesignPatterns.git'
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.
2、問題分析:
出現錯誤的主要原因是github中的README.md檔案不在原生代碼目錄中。
3、解決方法:
(1)可以通過如下命令進行程式碼合併【注:pull=fetch+merge】
git pull --rebase origin master
(2)再執行語句:
git push -u origin master
即可完成程式碼上傳到github。
去github上即可看到上傳的專案
---------------------
作者:此生小會
來源:CSDN
原文:https://blog.csdn.net/cckavin/article/details/80073711
版權宣告:本文為博主原創文章,轉載請附上博文連結!