我们的远程主分支莫名其妙地搞砸了。当前的开发代码与最新的提交一起在主分支上。显然,开发代码尚未准备好用于主分支。如何强制将重置推送到远程存储库?
因此,在我的本地存储库中,我重置了最新的标记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)'
我不能做一个拉的高手,因为它包含了开发代码不能上主。
我认为这个消息意味着你没有权利做非快进推送。 – svick
你是对的,谢谢。在远程存储库的配置文件中,'denyNonFastforwards = true'。我将它更改为false,推送了我的更改,然后将其更改为true。再次感谢所有人,寻求帮助。 – samwell
@samwell请将svick的答案标记为已接受 – hultqvist