Git branching strategies define how teams collaborate on code. The right strategy depends on team size, release cadence, and deployment frequency.
Git Flow: develop, feature, release, hotfix, and main branches. Structured but heavyweight. Good for scheduled releases.
GitHub Flow: simple main + feature branches with pull requests. Deploy from main. Best for continuous deployment with short-lived branches.
Trunk-based development: everyone commits to main (or short-lived branches merged within a day). Feature flags control feature visibility. Fastest integration.
GitLab Flow: environment branches (dev, staging, main) with cherry-picks between them. Good for multi-environment deployments.
Best practices: keep branches short-lived, use descriptive branch names (feature/add-login), delete merged branches, and protect main with required reviews.
Merge vs rebase: merge preserves history, rebase creates linear history. Use merge for shared branches, rebase for personal branches.