onlywei / explain-git-with-d3

Use D3 to visualize simple git branching operations.
MIT License
1.71k stars 390 forks source link

Arrows pointing the wrong direction #70

Open TheOfficialLoren opened 5 years ago

TheOfficialLoren commented 5 years ago

Shouldn't the arrows between commits be pointing in the opposite direction? i.e., The arrow from the first commit should point to the 2nd commit. The 2nd commit should merge to the 3rd.

And during a merge, the arrow should point from the source branch to the target branch.

Or am I completely misunderstanding something?

waldyrious commented 5 years ago

@lorengphd that's a common issue that people have when trying to understand how git works. The direction of the arrows has to do with how the commits are linked together. Each commit in git points to the commit that preceded it (it can point to more than one, in the case of a merge commit). That information is available to the new commit when it's being created, but not to the older commit. (That would require knowing the future!)

Of course, git could simply edit the parent commit to point to the child commit, but the entire point of commits is that they're immutable. So the only way to link them is from child to parent, not the other way around.

Hope that helps! Let me know if anything is unclear.