处理提交而不合并

时间:2013-12-08 15:00:06

标签: git

我从另一个程序错误地推了git。

现在我尝试

git push origin master 

从正确的位置和提交。

然而它说。

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我理解这条消息的含义,

但我不想合并最后一次提交(因为它完全错误!)

我想在没有git pull的情况下强行覆盖提交。

我该怎么做?

1 个答案:

答案 0 :(得分:4)

您可以使用git push --force重写远程仓库的历史记录并删除错误的提交。
请注意,这会破坏任何已经撤回该提交的人。