aircraft aircraft - 16 days ago 5
Git Question

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
:

now only show from the commit

Answer

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