我从另一个程序错误地推了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的情况下强行覆盖提交。
我该怎么做?
答案 0 :(得分:4)
您可以使用git push --force
重写远程仓库的历史记录并删除错误的提交。
请注意,这会破坏任何已经撤回该提交的人。