如何把最後一次commit
撤銷回Changes not staged
和Untracked files
區呢?
有3種情況:
(1)把最後的commit
切回Changes to be committed狀態,使用命令:
git reset --soft HEAD^
注意:Windows系統需要在^
符號後面兩邊加上引號,如:
git reset --soft HEAD"^"
(2)把最後的commit
切回Changes not staged for commit狀態,使用命令:
git reset HEAD^
(3)把Changes to be committed狀態切回Changes not staged for commit狀態,使用命令:
git reset HEAD <file>... # 單個文件 git reset HEAD -- . # 所有Changes to be committed的文件
最後一條命令在git命令行也有提示,不需要記住。
參考資料: