aircraft aircraft - 1 year ago 82
Git Question

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

Today I use

, commit , the info is:

and after I do something wrong, I reset back to a old
which info is:

and now I want to go to the
, but when I
git log
, not show my

now only show from the commit

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download