推送到分支而不从其他存储库获取更新

use*_*021 2 git github

我去推动工作到我的主分支,但我得到这个错误:

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/Machinas/esprit-rwd'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushin
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)

我不想获取另一个人提交的更新,因为这是他们的错误,我怎么能推动并忽略该提交?谢谢

Ame*_*sse 8

如果你真的确定其他提交不相关,你可以做一个强制推送:

git push --force-with-lease <remote> <branch>
Run Code Online (Sandbox Code Playgroud)

警告:如果其他人已经错误提交,你会让他们不高兴.犯错误的人应该更好地获得你的回购的新克隆.

编辑:改为--force,--force-with-lease因为后者有点危险.这篇Atlassian博客文章解释了原因.