git重置头~1
我的印象是 ~1 意味着:从 HEAD 开始,跟随 1 链接,并将 HEAD 标记设置为那个新的提交节点。我期待
git重置头~2
跟随 2 个链接,然后设置 HEAD 标签。但是,如果我尝试它,我会得到一个错误:
$ git reflog
c83bbda HEAD@{0}: reset: moving to HEAD~1
44c3540 HEAD@{1}: commit: you will be garbage soon
c83bbda HEAD@{2}: reset: moving to HEAD~1
aee7955 HEAD@{3}: commit: back to 4 lines
c83bbda HEAD@{4}: reset: moving to HEAD~1
19ec1d5 HEAD@{5}: commit: 3 lines
c83bbda HEAD@{6}: reset: moving to HEAD~1
a049538 HEAD@{7}: commit: added new line
c83bbda HEAD@{8}: commit (initial): first commit
$ git reset --hard HEAD~2
fatal: ambiguous argument 'HEAD~2': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
显然我弄错了,但是 git reset 的文档页面在澄清这一点方面并不是很有用。那么,~1 是什么意思,我为什么需要它?