:::info 误操作以后,可以回退到以前的commit。 :::
命令
git reset [-q] [<tree-ish>] [--] <paths>…
git reset (--patch | -p) [<tree-ish>] [--] [<paths>…]
EXPERIMENTAL: git reset [-q] [--stdin [-z]] [<tree-ish>]
git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
参数
- —hard:回退到对应的版本
修改文件提交版本
git add index.html
git commit -m "第二次提交"
查看提交日志
git log
回退到第一次提交
git reset --hard 291acd7c2ca10684b1fa6430724bbc14e4ab31e5
回退后悔
回退以后,又后悔了,不想回退,此时查看提交日志
发现已经没有了回退版本以后的记录,没了 commit_id ,就没办法回退
查看命令历史记录
git reflog
回退到对应版本
git reset --hard 588484e