A branch is a groove — a channel a history travels along. A commit is a raised dot on it. A fork point is a hollow one, because it is not a commit of that branch at all. Three shapes, and the four questions below answer themselves.一条分支是一道凹槽 —— 历史从里面走过的通道。一次提交是槽上的一个凸点。分叉点是空心的,因为它根本不是这条分支的提交。三种形状,下面四个问题就自己有了答案。
A branch is a groove running left to right and a commit is a raised dot sitting on it. The merge commit takes the accent, because the question a reader brings to a commit graph is almost always where did these two come back together — and a hollow dot is a point a branch was cut from, not a commit of its own.一条分支是一道从左往右的凹槽,一次提交是压在槽上的凸点。合并提交给强调色,因为读提交图的人问的几乎永远是这两支在哪汇回去的 —— 而空心的点是分支从那里切出来的位置,不是它自己的提交。
Three clones of one repository, and the shape is the permission: the one that can push is raised, the fetch-only ones are grooves. This is not a convention to remember — the push remote is physically removed from the sunken ones. A capability you can only break by editing config is worth more than one you keep by being careful.同一个仓库的三份克隆,而且形状就是权限:能推的凸起,只能 fetch 的是凹槽。这不是记在心里的约定 —— 凹的那两个 push 远端是物理删掉的。一个只能靠改配置才能破坏的限制,比一个靠小心保持的限制值钱。
The only clone that can push. Kept small and never built in, so a stray object file can never ride along with a commit.唯一能推的克隆。保持干净、从不在里面编译,所以一个漏下的目标文件永远搭不上提交的车。
Where the build runs. Fetch-only on purpose — the push remote is removed, not just discouraged.编译在这里跑。故意设成只能 fetch —— push 的远端是删掉的,不是靠自觉不推。
A fresh clone of what was actually pushed. If it builds here, the commit is complete; if it does not, something only existed on your disk.把真正推上去的东西重新克隆一份。在这里编得过,提交才是完整的;编不过,说明有东西只存在于你自己的盘上。
The same change carried onto three product branches. The commit ids differ because cherry-pick rewrites them — which is exactly why you cannot ask git whether product C already has it by comparing hashes. The hollow dot is the branch that has not taken it, and that is the only thing this figure is for.同一个改动搬到三条产品分支上。提交 id 各不相同,因为 cherry-pick 会重写它们 —— 这正是你没法靠比对 hash 去问 git「产品 C 拿到没有」的原因。空心的那个点是还没拿的分支,这张图就为说这一件事而存在。
Three refs on one axis. Hollow dots are the commits a ref already shares with the others, raised ones are what only it has. Ahead and behind are not opposites — this layout shows a branch that is three ahead of its own remote and two behind upstream at the same time, which is the state that makes people run the wrong command.一根轴上三个 ref。空心点是这个 ref 和别人共有的提交,凸起的是只有它自己有的。领先和落后不是对立的两件事 —— 这张图画的分支同时领先自己的远端 3 个、落后上游 2 个,而这正是让人敲错命令的那种状态。