--- name: git-workflow description: | Git workflow expert covering branching strategies, commit conventions, interactive rebase, merge vs rebase, conflict resolution, git bisect, hooks, monorepo strategies, and CI integration. Use when the user asks about git workflow, git workflow best practices, or needs guidance on git workflow implementation. Do NOT use when the user needs a different specialized skill or is asking about an unrelated technology domain. license: Apache-2.0 metadata: author: foundry-skills version: "1.0.0" tags: "best-practices version-control guide" category: "software-engineering" subcategory: "developer-tools" depends: "" disclaimer: "none" difficulty: "intermediate" --- # Git Workflow You are an expert in Git workflows. Design and execute Git strategies that keep history clean, enable collaboration, and support CI/CD. Git is a tool for communication between developers across time. Every commit, branch, and merge tells a story. ## Branching Strategies ### Trunk-Based Development (Recommended for Most Teams) ``` main ─────●─────●─────●─────●─────●─────●───── \ / \ / \ / ● ● ● (short-lived feature branches, < 2 days) ``` **Rules**: - `main` is always deployable. - Feature branches live less than 2 days. - Use feature flags for incomplete features. - CI runs on every push. Broken builds are fixed immediately. - Release from `main` using tags or short-lived release branches. **Best for**: Teams with CI/CD, experienced developers, frequent releases. ### GitHub Flow ``` main ─────●─────────●─────────●───── \ / \ ●──●──● ●──● (feature/xyz) (fix/abc) | Pull Request ``` **Rules**: - `main` is always deployable. - Create a branch from `main` for every change. - Open a PR for review. - Merge via PR after approval and CI pass. - Deploy from `main` after merge. **Best for**: Open-source projects, small-to-medium teams, web applications. ### GitFlow ``` main ────────●───────────────●───── (releases only) \ / develop ──●──●──●──●──●──●──●──── (integration) \ / \ / ●──● ●──● (feature) (feature) \ release/1.0 ──●──● \ hotfix/1.0.1 ``` **Rules**: - `main` tracks production releases. - `develop` is the integration branch. - Feature branches merge to `develop`. - Release branches stabilize the release. - Hotfix branches patch production directly. **Best for**: Products with scheduled releases, mobile apps, enterprise software with support contracts. ### When to Use Which | Factor | Trunk-Based | GitHub Flow | GitFlow | |--------|-------------|-------------|---------| | Release frequency | Continuous | Daily-weekly | Scheduled | | Team size | Any | Small-medium | Medium-large | | CI/CD maturity | High | Medium | Any | | Feature flags | Required | Optional | Not needed | | Complexity | Low | Low | High | ## Commit Message Conventions ### Conventional Commits ``` ():