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