如何覆盖已经push到git远程库的内容


在写个小项目,简单说就是经过了阶段a,阶段b和阶段c,阶段c已经push到了远程库。
我现在在我的本地库把版本reset到了阶段b,现在我希望能重新push,覆盖并舍弃已有的阶段c,但是遭到了拒绝:


 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:qianjiahao/chatroom.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate 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,然后修改了后在push回去,不知道还有没有其他的解决方法。

github git

Bello 10 years, 7 months ago

 git push --force

但愿有天堂 answered 10 years, 7 months ago

Your Answer