root@WSWINCNHZ1751 ~/git/learngit (master) $ git add distribution.txt root@WSWINCNHZ1751 ~/git/learngit (master) $ git commit -m 'the no.2' [master 327f725] the no.2 1 file changed, 1 insertion(+) root@WSWINCNHZ1751 ~/git/learngit (master) $ git log commit 327f725bdd84f56fef348ea1d78389a3e63d4f7b Author: root<[email protected]> Date: Fri Oct 16 11:19:03 2015 +0800 the no.2 commit 7662ba2604a0f513a9f0de1449b56a369ffbbb7b Author: root<[email protected]> Date: Fri Oct 16 11:12:55 2015 +0800 the No.1 distribution commit c91592279dd0e94b9f89208d9c35a936abc2243a Author: root<[email protected]> Date: Fri Oct 16 10:41:04 2015 +0800 change by me!! commit 1eddba5c91e3ba8e032a16ae1de7182a62394003 Author: root<[email protected]> Date: Fri Oct 16 10:38:38 2015 +0800 I made a modification commit 2ccb7e64765540603494d7eb284d86c94019562d Author: root<[email protected]> Date: Wed Oct 14 19:10:48 2015 +0800 learning git root@WSWINCNHZ1751 ~/git/learngit (master) $ git reflog 327f725 HEAD@{0}: commit: the no.2 7662ba2 HEAD@{1}: commit: the No.1 distribution c915922 HEAD@{2}: reset: moving to head^ 0fa8103 HEAD@{3}: reset: moving to 0fa810 c915922 HEAD@{4}: reset: moving to HEAD^ 0fa8103 HEAD@{5}: commit: add distributed c915922 HEAD@{6}: commit: change by me!! 1eddba5 HEAD@{7}: commit: I made a change 2ccb7e6 HEAD@{8}: commit (initial): learning git
log - Displays the record of the commit [commit]. A long string of hexadecimal characters following the commit is the version ID.
Although the log shows the commit record, not all operations are displayed. If there are 3 versions now
Version number: 333***
Version number: 222***
Version number: 111***
I now use git reset --hard 222 to go back to version 222,
I can't see version 333 after git log
You must use git relog to see the 333 version number before 222
Then restore to 333 via git r5eset --hard 333
reflog - This shows the history of all version changes.
The official English explanation is: Reflog is a mechanism to record when the tip of branches are updated. This command is to manage the information recorded in it.
The 7 characters in the result are the first few characters of the long string of version id characters, for example, 327f725 is the first few characters of 327f725bdd84f56fef348ea1d78389a3e63d4f7b.
reset - Reset current HEAD to the specified state
Repoints the currently pointed version to a specified state. The [specified state] here means that it is identified by the version id or HEAD^, HEAD^^, HEAD 100 and other methods. HEAD represents the current version. When we re-specify the version, the point of HEAD will change.