把先前的 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