简体   繁体   中英

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 .

and after I do something wrong, I reset back to a old commit which info is: 2016-10-18 careless.

and now I want to go to the 2016-11-25 , but when I git log , not show my 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 --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. Now restore your branch via the following:

git checkout yourBranch
git reset --hard b28ae3b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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