版本控制 (Git) 是 CI/CD 构建的基础 — repository 中的代码更改触发管道,而分支策略决定了 CI/CD 如何运行。Git 和 CI/CD 的集成使得自动化、变更驱动的交付成为可能。
Git 触发 CI/CD
CI/CD pipelines are TRIGGERED by Git events:
→ a PUSH to a branch → runs CI (build + test) on that change
→ a PULL REQUEST → runs CI to verify the change before merging
→ a MERGE to main → may trigger deployment (CD)
→ a TAG (e.g. v1.2.0) → may trigger a release/production deployment
→ Every code change in Git automatically drives the pipeline → change-driven automation.
分支和 CI/CD
→ FEATURE BRANCHES → CI runs on each (build/test the branch); PRs must pass CI to merge
→ MAIN branch → kept always working (green); merges trigger deployment to staging/prod
→ Different branches can map to different ENVIRONMENTS or pipeline behaviors
(e.g. main → production; develop → staging)
→ BRANCH PROTECTION → require CI to pass + reviews before merging (quality gate)
