把先前的 commit 强制 push 到 repo
October 13, 2020
如果你已经 push 了一些代码,想要 force push 某个较早的 commit,可以这样做 shell git push origin +commit_sha^:branch_name
其中 git 会把 sha^ 理解为 sha 的父 commit,把 + 理解为强制的 non-fastforward push。
你也可以使用 HEAD^,其中 ^ 代表 HEAD 的父 commit,所以 HEAD^^^ 会推送当前 commit 往前数第 3 个的那个 commit。 例如 shell git push origin +HEAD^^^:feature/i_did_an_oopsie