A protected main branch is a coordination boundary: changes enter through reviewed commits that satisfy checks, while production deployment refers to a specific commit or artifact. Short-lived branches reduce the time two developers spend editing divergent versions. A branch name is not a release identity because its target can move.
Git change control: small merges and protected branches
Operational decision
For a claims service, split a schema migration and its reader change into compatible steps that can merge independently. Require the integration checks on the final merge result, not merely an old branch head. Review the changed behavior, migration path, and recovery plan. Prefer a small pull request that exposes one decision over a large batch that is difficult to revert. When a protected branch needs an emergency change, use an auditable exception with an owner and follow-up review. The command below verifies the commit recorded in a release file against the local repository before building; the actual protection policy is configured in the hosting service. Preserve commit identity when promoting an artifact, even if the release label is more readable to operators.
expected_commit=$(cat release/claims-commit.txt)
actual_commit=$(git rev-parse HEAD)
test "$actual_commit" = "$expected_commit"
git status --porcelainCost and verification
Frequent small merges create more CI runs but generally make failures easier to isolate. Cost also comes from review queue time; measure it before adding a blanket approval layer. The status command prints uncommitted changes but does not fail when output exists, so a real build script must reject a dirty tree explicitly. A protected branch cannot guarantee the runtime is healthy; it controls entry to source history, not deployed behavior.
Common Mistakes
- Do not deploy a moving branch name as the release identity.
- Do not assume a successful check on an old branch head covers the merge result.
- Do not bypass branch rules without a recorded incident or exception.
Connected lessons
- DevOps Tutorial
- Continuous integration: test the merge candidate
- Database change safety: expand, migrate, contract
- Immutable artifacts and release provenance
