原文地址: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命令行也有提示,不需要记住。

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2021-04-17
  • 2021-05-15
  • 2022-12-23
  • 2021-09-20
  • 2021-11-04
猜你喜欢
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案