如何解決error: failed to push some refs


$ git push -u origin master To github.com:a653398363/testtest.git ! [rejected]        master -> master (fetch first) error: failed to push some refs to 'git@github.com:a653398363/testtest.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.

 

1、在使用git 對源代碼進行push到gitHub時可能會出錯

2、出現錯誤的主要原因是github中的README.md文件不在本地代碼目錄中

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

git pull --rebase origin master

4、執行上面代碼后可以看到本地代碼庫中多了README.md文件

5、此時再執行語句 git push 即可完成代碼上傳到github


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM