我们的远程主分支不知何故搞砸了。当前的开发代码与最新的提交一起在主分支上。显然,开发代码还没有准备好用于 master 分支。
所以在我的本地存储库中,我重置了最新的标签,git reset --hard (Tag)
. master 分支现在在我的本地存储库上是正确的。现在,当我尝试将更改推送到远程存储库时,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 上做一个 pull,因为它包含不能在 master 上的开发代码。