如果更改 commit 到 GitHub 的 branch 且 push 過後想要復原,還原上一次 commit 的狀況 執行以下:
git log --online
查看目前線上的 commit 狀況
找到你想要復原的 commit 號
(例如圖中我想要刪除的 commit id 是 f05101b,也就是我想回復到 9d7a4ef commit 後的狀況)
git rebase [回復到這個 commit 完成後的狀況] (範例中我就執行: git reset 9d7a4ef)
這樣你本機的狀態就已經恢復,接下來要把這個 push 到線上
git push origin [+branchName] --force (範例中我執行 git push origin master,因為我要修改的就是在 master 這個 branch 的 commit)
參考來源: https://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github https://gitbook.tw/chapters/rewrite-history/remove-and-reorder-commit.html https://gitbook.tw/chapters/using-git/reset-commit.html