慘了!如何對已經 push 到 github 的 commit 做修改
目標 我想要把做錯的 commit (目前此 commit 已經 push 到 github 上了) 拆掉,再重新 push 上去。 目前的 commit log: (c. 最新 commit) feat: static import swiper image (b. 一般 commit) feat: dynamic import swiper image (a. 最舊 commit) feat: resize images & fix Carousel (拆掉 commit 再重新 push) 最終的 commit log: (c. 最新 commit) feat: static import swiper image 被合併 (b. 一般 commit) feat: dynamic import swiper image 被合併 (a. 最舊 commit) feat: resize images & fix Carousel (拆掉 commit 再重新 push) 被重新命名 (a. 最舊 commit) feat: static import swiper webp images 做法一:git reset 我把 commit 拆掉再重新 push! 切換到目標分支 $ git checkout [分支名稱] 檢視提交的歷史記錄 $ git log 拆掉 倒數兩個 commit aka. 最新&一般 commit (保留更改,但刪除已提交的歷史記錄),亦即透過 git reset 返回原本 倒數第三個 commit aka. 最舊 commit 的狀態 $ git reset --soft HEAD~2 將第二個和第三個 commit 的變動合併為一個新的 commit ...