远程的 develop 比你本地的 develop 更新,Git 拒绝直接覆盖
问题
cxq@DESKTOP-KS9ENIP MINGW64 /e/c++4/c-4 (develop)
$ git push origin develop
To https://gitee.com/beihangya/c-4.git ! [rejected] develop -> develop (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/beihangya/c-4.git '
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
原因:远程的 develop 比你本地的 develop 更新,Git 拒绝直接覆盖
解决路线
保守方案——先从远程仓库拉下来,然后将本地代码推送远程仓库
git pull origin develop --rebase # 把远程新提交拿下来,再把你本地提交叠在后面
git push origin develop
如果有冲突,解决后继续 git rebase --continue → git push