git 提交出現 Updates were rejected 解決方案


git remote add 添加一個遠程地址
但提交出現以下報錯


failed to push some refs to 'https://gitee.com/xxxxx/xxx-admin.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and 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.

解決
也就是說,如果您確定處於分離狀態的master版本是您真正想要保留的版本,那么您可以通過強制將分支推送到遠程來避免非快進錯誤:
git push origin HEAD:master --force

但是,如果強制推送,則可能會給簽出該分支的所有其他用戶造成問題。風險較小的解決方案是從分離的頭創建一個臨時分支,然后將該分支合並到主分支中:

git branch temp-branch
git checkout master
git merge temp-branch
git push origin master

說明 https://www.it1352.com/800159.html


免責聲明!

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



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