git初学---版本回退【上一个版本】与穿越【下一个版本】

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

    我做了一次修改

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: 我做了一次修改
2ccb7e6 HEAD@{8}: commit (initial): learning git


 

 log - 显示提交【commit】的记录,commit后面跟着的一大长串16进制字符为版本ID。

         虽然说log显示提交记录,不过并不是所有的操作都显示,如果现在有3个版本

           版本号:333***

           版本号:222***

           版本号:111***

           我现在用git reset —hard 222 退回到222版本,

           git log 后 就看不到333版本了

           必须要用git relog才能看到222之前的333版本号

           然后在通过git r5eset —hard 333 恢复到333

reflog - 这里显示所有版本变更的历史记录。

扫描二维码关注公众号,回复: 305142 查看本文章

英文官方的解释为:Reflog is a mechanism to record when the tip of branches are updated. This command is to manage the information recorded in it.

结果中的那7位字符是那一大长串版本id字符的前几位,如327f725就是327f725bdd84f56fef348ea1d78389a3e63d4f7b的前几位。

reset - Reset current HEAD to the specified state

         将当前的指向的版本重新指向一个指定的状态。这里的【指定的状态】表示用版本id或HEAD^, HEAD^^, HEAD 100等方法来标识的。HEAD代表当前的版本,当我们重新指定版本后,HEAD的指向也就变了。

猜你喜欢

转载自bekylin.iteye.com/blog/2249593