项目场景:
今天用git push进行提交时,出现如下错误:
D:\app\myapp>git push
To https://。。。。。
! [rejected] develop -> develop (non-fast-forward)
error: failed to push some refs to 'https://。。。。'
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.
问题描述:
未能将一些引用推送到远程仓库。
原因分析:
百度了一下,有相关的解决办法,原来是远程库与本地库不一致造成的,把远程库同步到本地库就可以了。
解决方案:
使用命令行
git pull --rebase origin develop
该命令的意思是把远程库中的更新合并到本地库中,–-rebase的作用是取消掉本地库中刚刚的commit,并把他们接到更新后的版本库之中。然后再执行git push就没问题了。
参照了bluetata的解决方法
更详细问题发生原因