Branches(分支)在 Git 中让你能够从开发的主线分离出来,在隔离环境中工作 — 不影响主代码。它们是轻量级的,是 Git 工作流的核心,支持并行工作和安全的实验。
什么是分支
A branch is a MOVABLE POINTER to a commit. The default is usually "main".
→ creating a branch = creating a new pointer (cheap/instant — not a copy of files)
→ commits on a branch advance that branch's pointer
→ branches let you work on different things in parallel, isolated from each other
分支是轻量级的(只是指向提交的指针,不是副本)— 所以创建和切换分支很快且成本低,这就是为什么 Git 分支被广泛使用的原因。
