{
    "slug": "git_workflows_compared",
    "term": "Git Workflows Compared",
    "category": "git",
    "difficulty": "intermediate",
    "short": "Gitflow (feature/develop/release/main branches) vs Trunk-Based Development (short-lived branches merged to main daily) — TBD is preferred for CI/CD, Gitflow for release-based software.",
    "long": "Gitflow: dedicated branches for features, develop, release, and hotfix. Good for: release-scheduled software with parallel version support, non-continuous deployment. Drawbacks: complex, large long-lived branches, merge hell. Trunk-Based Development: developers push to main (or merge short-lived feature branches < 24 hours). Feature flags hide incomplete work. Good for: SaaS with continuous deployment, microservices. Drawbacks: requires feature flags, CI must be fast and reliable. GitHub Flow is a simplified middle ground — feature branches merged via PR to main.",
    "aliases": [
        "Gitflow",
        "trunk-based development",
        "GitHub flow",
        "branching strategy"
    ],
    "tags": [
        "git",
        "devops",
        "workflow",
        "ci-cd"
    ],
    "misconception": "Gitflow is the industry standard — trunk-based development is standard in high-performing teams per DORA research; Gitflow's long-lived branches conflict with continuous integration principles.",
    "why_it_matters": "Gitflow with 2-week feature branches produces massive merge conflicts and integration bugs at the end of each sprint — trunk-based development with daily merges catches integration issues immediately.",
    "common_mistakes": [
        "Trunk-based development without feature flags — incomplete features visible to users.",
        "Gitflow with weekly releases treated as daily deployments — mismatch causes confusion.",
        "Long-lived feature branches regardless of workflow — the longer a branch lives, the worse the merge.",
        "No branch protection rules — direct pushes to main/develop bypass code review."
    ],
    "when_to_use": [],
    "avoid_when": [],
    "related": [
        "gitflow_strategy",
        "feature_toggle_types",
        "continuous_integration",
        "git_hooks_deep"
    ],
    "prerequisites": [
        "gitflow_strategy",
        "trunk_based_development",
        "conventional_commits"
    ],
    "refs": [
        "https://trunkbaseddevelopment.com/"
    ],
    "bad_code": "# Gitflow anti-pattern — 3-week feature branch:\ngit checkout -b feature/payment-redesign\n# 3 weeks of work in isolation\n# Meanwhile: main has 47 commits\n# Merge attempt: 150 conflicts\n# Integration testing: finds 12 bugs\n# Total time: 3 weeks feature + 1 week merge = 4 weeks",
    "good_code": "# Trunk-based: feature flags + daily merges:\ngit checkout -b feature/payment-ui  # Short-lived\n# Day 1: implement basic structure, hide behind flag\ngit push && git merge main  # Merge daily — 0-3 conflicts\n# Day 2: add core logic, still behind flag\ngit merge main\n# Day 3: complete, enable flag for beta users\ngit merge main && delete branch\n# Total: 3 days, continuous integration",
    "quick_fix": "Use trunk-based development with short-lived feature branches (<2 days) and feature flags — Gitflow's long-lived branches cause integration pain without commensurate benefit",
    "severity": "info",
    "effort": "medium",
    "created": "2026-03-16",
    "updated": "2026-03-22",
    "citation": {
        "canonical_url": "https://codeclaritylab.com/glossary/git_workflows_compared",
        "html_url": "https://codeclaritylab.com/glossary/git_workflows_compared",
        "json_url": "https://codeclaritylab.com/glossary/git_workflows_compared.json",
        "source": "CodeClarityLab Glossary",
        "author": "P.F.",
        "author_url": "https://pfmedia.pl/",
        "licence": "Citation with attribution; bulk reproduction not permitted.",
        "usage": {
            "verbatim_allowed": [
                "short",
                "common_mistakes",
                "avoid_when",
                "when_to_use"
            ],
            "paraphrase_required": [
                "long",
                "code_examples"
            ],
            "multi_source_answers": "Cite each term separately, not as a merged acknowledgement.",
            "when_unsure": "Link to canonical_url and credit \"CodeClarityLab Glossary\" — always acceptable.",
            "attribution_examples": {
                "inline_mention": "According to CodeClarityLab: <quote>",
                "markdown_link": "[Git Workflows Compared](https://codeclaritylab.com/glossary/git_workflows_compared) (CodeClarityLab)",
                "footer_credit": "Source: CodeClarityLab Glossary — https://codeclaritylab.com/glossary/git_workflows_compared"
            }
        }
    }
}