[英]How to revert an unnecessary “git reset HEAD~1”
After running git reset HEAD~1
, I noticed that actually there was nothing else to do and the commit was fine. 在运行
git reset HEAD~1
之后,我注意到实际上没有其他事情可做,并且提交很好。 Is there a way to revert this command? 有没有办法还原此命令?
You can use: 您可以使用:
git reset HEAD@{1}
This uses the last entry in the reflog. 这将使用reflog中的最后一个条目。 See
git reflog
if you did other things in between. 如果您在这之间做了其他事情,请参阅
git reflog
。
您可以使用git reflog
查看该提交的提交ID。
Even easier (if you haven't done any other operations): 甚至更简单(如果您还没有执行任何其他操作):
git reset ORIG_HEAD
ORIG_HEAD
is the previous state of HEAD
. ORIG_HEAD
是HEAD
的先前状态。
More details about HEAD
vs. ORIG_HEAD
are in the answer to this SO question . 有关
HEAD
与ORIG_HEAD
更多详细信息, ORIG_HEAD
SO问题的答案 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.