Referencing the child of a commit in Git

后端 未结 10 1147
失恋的感觉
失恋的感觉 2020-11-28 08:37

If you want to move the HEAD to the parent of the current HEAD, that\'s easy:

git reset --hard HEAD^

But is there

10条回答
  •  孤街浪徒
    2020-11-28 09:14

    It depends on what you're asking. There could be an infinite number of children of the current head in an infinite number of branches, some local, some remote, and many that have been rebased away and are in your repository, but not part of a history you intend to publish.

    For a simple case, if you have just done a reset to HEAD^, you can get back the child you just threw away as HEAD@{1}.

提交回复
热议问题