Git 修改上次的 commit

有時候 ShengYu 想加入某些檔案的修改在前一筆 commit 紀錄裡, 都是透過下面幾個指令就快速搞定囉!

將你想要加入的檔案用 git add 加一加, 最後在 git commit 後面加上 --amend
指令操作如下:

1
2
git add <filename>
git commit --amend

其他參考
git - How to modify existing, unpushed commit messages? - Stack Overflow
https://stackoverflow.com/questions/179123/how-to-modify-existing-unpushed-commit-messages
【狀況題】追加檔案到最近一次的 Commit - 為你自己學 Git | 高見龍
https://gitbook.tw/chapters/using-git/amend-commit2.html
【狀況題】修改 Commit 紀錄 - 為你自己學 Git | 高見龍
https://gitbook.tw/chapters/using-git/amend-commit1.html
Commit –amend【教學3 改寫提交】 | 連猴子都能懂的Git入門指南 | 貝格樂(Backlog)
https://backlog.com/git-tutorial/tw/stepup/stepup7_1.html