首先我们明白两个命令的作用:

  • git add把文件修改添加到暂存区;
  • git commit提交更改,把暂存区的所有内容提交到当前分支。

从暂存区里面恢复至普通文件(绿字变红字):
如果是撤销所有的已经add的文件:git reset HEAD .
如果是撤销某个文件或文件夹:git reset HEAD -filename

版本回退,也就是回退某个commit:git reset --hard 版本号(版本号就是通过git status获取)
撤销没add文件的修改(红字变无) :git checkout --filename
7.jpg

Last modification:September 4, 2019
If you think my article is useful to you, please feel free to appreciate