git 報錯 :Updates were rejected because the tip of your current branch is behind 解決方法


 

 報錯

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

博主:第一次新增了一個倉庫並且倉庫中新增readme的文件。

  首次次將本地的文件上傳git倉庫,到了最后一步git push origin master就報上面的錯誤。

報錯原因:因為遠程倉庫有的文件,本地沒有。因此報錯

第一種解決辦法:刪除遠程git倉庫的文件,再進行推

第二種強制推送並且覆蓋遠程git倉庫:git push -f origin master

注意:千萬不要用:git pull --rebase origin master這個命令,這個命令,拉遠程git倉庫文件,並且覆蓋本地文件。因此就會把我們本地還沒有上傳git的文件給覆蓋掉,我們本地寫的東西就沒了

 


免責聲明!

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



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