如何判断哪个 GIT child 是新分支?

How to tell which GIT child is a new branch?

大家都好吗?让 运行 遇到 GIT 的问题,我无法确定哪个 child 节点与 parent 在同一分支上,哪个是新分支: git tree example for below commits

可以看出,local/remote项目中有标签,没有分支名称。

tag "3.2ECHO1.1" -> parent: d42624
first green commit -> child 1: c1749e
first pink commit -> child 2: 404c71

如果我运行以下任何命令:

git branch -a --contains c1749e
git branch -a --contains 404c71
git branch -a --contains d42624

结果是每个空行。

问题:给定一个 git parent 提交,如何确定哪个 child 在同一分支上,哪个 child 是新分支?我想将这个项目的确切结构重新创建到一个新项目中。

谢谢

parent 从未包含过 child。 Children 包含 parent 的后代,反之亦然。箭头指向后方,而不是前方。

在 git 中,分支 并不真正存在 。分支实际上以与标记相同的方式记录,只是更频繁地移动:它指向单个提交,因此与通过其唯一哈希相比,您可以更方便地引用该提交。从那个单一的提交,你可以到达那个提交的每个祖先,通过跟随“parent”指针返回到存储库的根。

I would like to recreate the exact structure of this project into a new project.

项目的结构您展示的图表;它被记录为一系列不可变的提交,每个提交都有零个或多个对“parents”的引用 - 1 个用于“正常”提交,2 个用于典型的“合并提交”。 parents 存储为有序列表,按照惯例,第一个 parent 是合并发生时检出的提交;因此图形视图将尽量使第一行 parent 更直。

没有关于创建、移动或删除分支指针的位置的记录,因此如果分支现在不存在,您将无法重新创建它们 - 即使它们 存在现在就存在,你不一定能准确地说出他们的历史。

given a git parent commit, how does one determine which child is on the same branch and which child was a new branch?

你必须反过来:给定某个分支指针的当前位置,你可以确定特定的 parent 提交是否在该分支的当前历史记录中。但是深入到存储库,您的提交将成为 每个 当前分支的祖先;无法选择哪个是“必须相关”的后代。