我在推送时不断从git收到此错误消息,即使我在翻过来之后尝试它:
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '[repo url]' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.
以下是分支历史记录的样子:
A---B---C
| |
D E-F
A initial commit (me)
B some commit (me)
C master
D some commit (other dev)
E remotes/origin/master - Merge branch 'master' of [repo url]
F Local uncommitted changes, not checked into an index
Run Code Online (Sandbox Code Playgroud)
从这里开始,当我拉,没有任何东西来.当我推,我得到错误.我怎样才能再次成功推送?
小智 5
我遇到了这个问题,原因如下:
我的机器中的本地分支(具有不同的来源)未更新(并且已被其他用户修改).您必须移动到尚未更新的分支(git checkout [branch in question])并执行git pull.
这解决了我的问题.在这种特殊情况下,由于此消息
"![拒绝]主人 - >主人(非快进)!"
你必须移动到主分支(git checkout master)做一个git pull,然后回到你正在处理的任何分支(git checkout whateverBranch),现在你应该能够毫无问题地进行推送.
我不明白为什么会这样; 可能是git push的本质是检查推送时没有正确更新的所有本地分支.