在 push 代码到远程仓库时出现版本冲突
错误示例:
$ git push origin develop
To https://github.com/***.git
! [rejected] develop -> develop (non-fast-forward)
error: failed to push some refs to 'https://github.com/***.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.
原因:
github上的版本和本地版本冲突的解决方法
解决办法一:
强制覆盖已有的分支(不推荐):
git push -u origin master -f
解决办法二:
先pull远程仓库,然后再push
git pull origin master --allow-unrelated-histories (该选项可以合并两个独立启动仓库的历史)
git push -u origin master