DAG vs. tree using Git?

前端 未结 1 1757
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 06:02

I\'ve often read that Git uses the directed acyclic graph (DAG) data structure, with each commit as a node, and things like branches and tags as pointers to nodes.

B

相关标签:
1条回答
  • 2020-11-28 06:22

    But when I try to visualize my commit history using tools like gitk, it looks more like a tree than a graph since every parent-child relationship is directed one way.

    A DAG, like a tree, can be laid out such that all parent-child relationships are one-way. The difference between them is that nodes in a DAG can have multiple parents. The most common case of this in Git is when you do a merge. A merge commit will have all of the commits that were merged as parents. A tree doesn't allow nodes to have multiple parents.

    Graph with merging (Image source)

    Notice how the merge commit C6 has two parents, C4 and C5.

    0 讨论(0)
提交回复
热议问题