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

时间:2015-07-10 13:53:56

标签: 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.

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

1 个答案:

答案 0 :(得分:8)

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

git push --force-with-lease <remote> <branch>

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

编辑:将--force更改为--force-with-lease,因为后者的危险性稍差。这个Atlassian blog post解释了原因。