文章目錄
            
          
        
        
        
          當要修改最後一次 commit 紀錄時,直覺反應就是 git commit --amend
但由於 IntelliJ IDEA Git 整合度非常高,幾乎絕大部分操作都能透過 GUI 完成
以下介紹幾種在 IntelliJ 內修改 Git commit 紀錄的作法 (以 2018.3 為例)
情境:修改 commit log Commit 3
 
git commit
使用內建 Terminal
- 確定 Terminal 已啟用  
- 透過 Alt + F12開啟 Terminal
- 輸入 git commit --amend 
- 接下來就是 vi 畫面,按下小寫 i 後可以編輯內容;編輯完畢後按 Esc,接著輸入:wq即可儲存離開 
結果第一個就是打指令 (毆)
Commit 時勾選 Amend commit
勾選 Amend commit 重新 commit 即可,不過限制檔案內容有修改過 
你也可以選擇 Amend commit 兩次,例如把上圖的 Commit3 > Commit31 > Commit3,並打上要修正的 commit 紀錄 (超大誤)
git rebase
透過 Git rebase
- VCS > Git > Rebase…  
- 勾選 Interactive,並且 Onto 設定為 HEAD~ 
- 於 Action 選擇 reword後點選 Start Rebasing 
- 輸入要修正的 Commit 內容後點選 Resume Rebasing 
透過 Version Control reword
- View > Tool Windows > Version Control (或透過 Alt + 9開啟) 
- 右鍵 > Reword… (或透過 F2) 
- 輸入要修正的 Commit 內容後點選 OK
結語
雖然 IntelliJ 提供精美 GUI 幫助我們,但本質上還是 Git 指令 (是個易學難精的版控😂)
推薦兩位大神的精美文章-
底下則是本篇文章運用到的 Git 指令