git reset

git reset

还原提交记录。


# 重置暂存区,但文件不受影响 # 相当于将用 "git add" 命令更新到暂存区的内容撤出暂存区,可以指定文件 # 没有指定 commit ID 则默认为当前 HEAD
$ git reset [<文件路径>]
$ git reset --mixed [<文件路径>]

# 将 HEAD 的指向改变,撤销到指定的提交记录,文件未修改
$ git reset <commit ID>
$ git reset --mixed <commit ID>

# 将 HEAD 的指向改变,撤销到指定的提交记录,文件未修改
# 相当于调用 "git reset --mixed" 命令后又做了一次 "git add"
$ git reset --soft <commit ID>
 
# 将 HEAD 的指向改变,撤销到指定的提交记录,文件也修改了
$ git reset --hard <commit ID>

 

 

posted @ 2021-02-03 15:05  joyce3800  阅读(60)  评论(0)    收藏  举报