How can we refer to a child of a commit?

后端 未结 2 539
梦如初夏
梦如初夏 2021-01-22 17:18

Given a branch name or a tag name, we can refer to its parent by name~1. Can we refer to one of its children in some way?

Thanks.

2条回答
  •  情深已故
    2021-01-22 17:54

    A Git repository is represented as a DAG (directed, acyclic graph) of commits. Each commit includes one pointer to each of its parents, but no information about what commits have it as a parent. That's why you can only refer to the parents of a commit (name~1, name~2, etc), not the commits that have name as a parent.

    (Most commits have a single parent, but a merge commit is an example of a commit with 2 or more parents, depending on how many branches were involved in the merge.)

提交回复
热议问题