我们的远程主分支不知怎么搞砸了。当前的开发代码和最新的提交一起放在主分支上。显然,开发代码还没有为主分支做好准备。
因此,在我的本地存储库中,我重置了最新的标记 git reset --hard (Tag)
。主分支现在在我的本地存储库上是正确的。现在,当我试图将更改推送到远程存储库 git push origin master
时,我得到一个错误:
To (REMOTE GIT REPOSITORY LOCATION)
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '(REMOTE GIT REPOSITORY LOCATION)'
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.
因此,在环顾四周后,我发现了 --force
选项。因此,我向远程存储库 git push --force origin master
进行了一次强制推送,但仍然得到一个错误:
Total 0 (delta 0), reused 0 (delta 0)
remote: error: denying non-fast-forward refs/heads/master (you should pull first)
To (REMOTE GIT REPOSITORY LOCATION)
! [remote rejected] master -> master (non-fast-forward)
error: failed to push some refs to '(REMOTE GIT REPOSITORY LOCATION)'
我不能对 master 进行拉动操作,因为它包含不能在 master 上进行的开发代码。