【发布时间】:2020-03-13 05:25:21
【问题描述】:
我正在尝试学习git revert 命令。我正在尝试恢复比 HEAD 更早的提交。这是不允许的吗?
$ git touch sonic
$ echo sonic >> sonic
$ git add .
$ git commit -m "sonic"
$ echo the >> sonic
$ git add .
$ git commit -m "the"
$ echo hedgehog >> sonic
$ git add .
$ git commit -m "hedgehog"
$ git log --oneline
d65e56d (HEAD -> master) hedgehog
e37fefc the
c745775 sonic
然后
$ git revert HEAD^
Auto-merging sonic
CONFLICT (content): Merge conflict in sonic
error: could not revert e37fefc... the
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
我可以做git revert HEAD,这将恢复 d65e56d 但不是git revert HEAD^。这根本不允许吗? git revert HEAD^^ 也不行。
【问题讨论】: