查看本地历史
使用 git reflog 查看本地操作历史,找到要回退的commit-id
bash
git reflog
查看相对时间日志
bash
git reflog --date=relative
优点:直观显示时间差(如"2小时前"),便于快速定位操作时间。
查看绝对时间日志
bash
git reflog --date=iso
优点:精确到秒级时间戳,适用于需要精确时间的场景。
查看本地时间日志
bash
git reflog --date=iso-local
说明:自动转换为本地时区时间。
回退到指定版本
使用 git reset --hard commit-id 回退到指定版本
bash
git reset --hard commit-id