简体   繁体   English

Git:重置为太旧的提交和git log,只显示我现在的提交

[英]Git: reset to a too old commit, and git log , only show from the commit I have now

Today I use git , commit , the info is: 2016-11-25 . 今天我用git ,commit,信息是: 2016-11-25

and after I do something wrong, I reset back to a old commit which info is: 2016-10-18 careless. 在我做错了之后,我重新回到了旧的commit ,其信息是: 2016-10-18粗心。

and now I want to go to the 2016-11-25 , but when I git log , not show my commit : 现在我想去2016-11-25 ,但是当我git log ,不显示我的commit

现在只显示提交

You can use Git's reflog feature, which is a sort of audit trail of all the things which happen as you use Git, including commits. 您可以使用Git的reflog功能,这是对使用Git时发生的所有事情的审计跟踪,包括提交。

git reflog --date=iso

Try to find an entry looking something like the following: 尝试查找类似以下内容的条目:

b28ae3b HEAD@{2016-11-25 15:54:53 +0800}: commit: message for the commit which you
made earlier today

If you can find the commit, record the SHA-1 hash ( b23ae3b in this example) because you will need it to restore your branch at that commit. 如果您可以找到提交,请记录SHA-1哈希(在此示例中为b23ae3b ),因为您将需要它来恢复该提交的分支。 Now restore your branch via the following: 现在通过以下方法恢复您的分支:

git checkout yourBranch
git reset --hard b28ae3b

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM