Git 中的“撤销”

(1)当commit 完后,发现少add几个文件,可以:

$ git commit -m 'initial commit'

$ git add forgotten_file

$ git commit --amend

(2) 修改了a.txt,但没有add 到暂存区,撤销到没有修改过该文件:

$ git restore a.txt

(3)修改了a.txt,add到了暂存区,没提交,撤销到没添加到暂存区:

$ git restore --staged a.txt

(4)回到某特定版本

$ git reset --hard ^HEAD

posted @ 2020-03-20 20:27  JohnYang819  阅读(125)  评论(0编辑  收藏  举报