git版本回退再返回
原本位于
commit 93d095b47554a84dafcd6cda73ff24e6fb6dbe0a (HEAD -> master)
Author: git_ming <2569439820@qq.com>
Date: Tue Aug 2 11:10:25 2022 +0800
其他文件添加错误
commit a01553b0c3486adbd2d41544417b3b14b5e6bf0b
Author: git_ming <2569439820@qq.com>
Date: Mon Aug 1 11:41:42 2022 +0800
junctionx modify export.py
commit dcb77aa36d7caed598c3cac51fadfe4400f808a7
Author: git_ming <2569439820@qq.com>
Date: Mon Aug 1 10:53:57 2022 +0800
junctionx1
commit f53e6fcf9f13c4ab6ff64e5baa43202f5880ee1b
Author: git_ming <2569439820@qq.com>
Date: Mon Aug 1 10:41:22 2022 +0800
junctionx
当前位于 提交记录为"junctionx"版,但想要返回上一版,但是git log
commit f53e6fcf9f13c4ab6ff64e5baa43202f5880ee1b (HEAD -> master)
Author: git_ming <2569439820@qq.com>
Date: Mon Aug 1 10:41:22 2022 +0800
junctionx
commit 0c6f7eb48fbcba2338859519a31601b2c76c0bb5 (origin/master, origin/HEAD)
Author: manu12121999 <manu12121999@gmail.com>
Date: Tue Jul 19 20:44:39 2022 +0200
Allow the export of 3way junctions
modified: addon/export.py
commit 45c9eda551b26402928c7958feac69ccb2b068c2 (tag: v0.12.0)
Author: Johannes Schmitz <johannes.schmitz1@gmail.com>
Date: Fri Jul 22 19:42:23 2022 +0200
Update version number and changelog
commit 5690e796da3836a70a57b9030f86159efff9d49c
Author: Johannes Schmitz <johannes.schmitz1@gmail.com>
Date: Fri Jul 22 19:10:59 2022 +0200
这时需要使用git reflog
git reflog
T: 管理提交列表
f53e6fc (HEAD -> master) HEAD@{0}: reset: moving to HEAD^
9f24176 HEAD@{1}: commit: add software icon
f53e6fc (HEAD -> master) HEAD@{2}: reset: moving to HEAD^
dcb77aa HEAD@{3}: reset: moving to dcb77aa36d7caed598c3cac51fadfe4400f808a7
93d095b HEAD@{4}: commit: 其他文件添加错误
a01553b HEAD@{5}: commit: junctionx modify export.py
dcb77aa HEAD@{6}: commit: junctionx1
f53e6fc (HEAD -> master) HEAD@{7}: commit: junctionx
0c6f7eb (origin/master, origin/HEAD) HEAD@{8}: clone: from https://github.com/johschmitz/blender-driving-scenario-creator.git
HEAD@{2} 表示“HEAD 曾经是两个移动
master@{one.week.ago} means “where master used to point to one week ago in this local repository”,
,如果想回到“ 93d095b 其他文件添加错误”;这时便可用git reset 复原
git reset --hard 93d095b
HEAD 现在位于 93d095b 其他文件添加错误
$ git log
commit 93d095b47554a84dafcd6cda73ff24e6fb6dbe0a (HEAD -> master)
Author: git_ming <2569439820@qq.com>
Date: Tue Aug 2 11:10:25 2022 +0800
其他文件添加错误
commit a01553b0c3486adbd2d41544417b3b14b5e6bf0b
Author: git_ming <2569439820@qq.com>
Date: Mon Aug 1 11:41:42 2022 +0800
junctionx modify export.py
commit dcb77aa36d7caed598c3cac51fadfe4400f808a7
Author: git_ming <2569439820@qq.com>
Date: Mon Aug 1 10:53:57 2022 +0800
junctionx1
commit f53e6fcf9f13c4ab6ff64e5baa43202f5880ee1b
Author: git_ming <2569439820@qq.com>
Date: Mon Aug 1 10:41:22 2022 +0800
junctionx
git log是显示当前的HEAD和它的祖先的,递归是沿着当前指针的父亲,父亲的父亲,…,这样的原则。
git reflog根本不遍历HEAD的祖先。它是HEAD所指向的一个顺序的提交列表:它的undo历史。reflog并不是repo(仓库)的一部分,它单独存储,而且不包含在pushes,fetches或者clones里面,它纯属是本地的。
reflog可以很好地帮助你恢复你误操作的数据,例如你错误地reset了一个旧的提交,或者rebase,…,这个时候你可以使用reflog去查看在误操作之前的信息,并且使用git reset --hard 去恢复之前的状态。
原文链接:https://blog.csdn.net/chaiyu2002/article/details/81773041
git reflog [show] [log-options] [<ref>]
git reflog expire [--expire=<time>] [--expire-unreachable=<time>]
[--rewrite] [--updateref] [--stale-fix]
[--dry-run | -n] [--verbose] [--all | <refs>...]
git reflog delete [--rewrite] [--updateref]
[--dry-run | -n] [--verbose] ref@{specifier}...
git reflog exists <ref>
“show”显示reflog条目
“expire”子命令会删除掉更老的reflog条目。
“delete”子命令从reflog中删除一个条目。
“exists”子命令检查一个ref是否有一个reflog。
参考
https://blog.csdn.net/chaiyu2002/article/details/81773041
https://blog.csdn.net/weixin_54272621/article/details/124479041