git 还原到某次commit

来源:互联网 发布:js array删除方法 编辑:程序博客网 时间:2024/05/17 03:14

不可逆提交

一,reset

1.git log查看提交记录

git log

2.选择某次提交的commit ID,ctrl+c复制提交ID

3.使用git reset –hard 还原到某一次提交

git reset --hard commit ID

这里写图片描述

二,checkout
1.git checkout commit ID ,这个命令达到的效果和git reset –hard一样都是不可逆提交

git checkout commit ID

可逆提交

一,checkout

1.git checkout 还原某个文件到某次commit

这里写图片描述

checkout 后再次查看提交记录,上一次的提交并没有被还原掉

这里写图片描述

未完待续