原文地址:https://www.awaimai.com/2383.html
如何把最后一次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命令行也有提示,不需要記住。