$npx -y skills add BagelHole/DevOps-Security-Agent-Skills --skill git-workflowImplement Git branching strategies, PR workflows, and release management patterns. Configure GitFlow, trunk-based development, or GitHub Flow for team collaboration. Use when establishing version control workflows or improving development team collaboration.
| 1 | # Git Workflow |
| 2 | |
| 3 | Implement effective branching strategies and pull request workflows for team collaboration. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | Use this skill when: |
| 8 | - Establishing team Git workflows |
| 9 | - Implementing branching strategies |
| 10 | - Configuring pull request processes |
| 11 | - Setting up release management |
| 12 | - Improving code review practices |
| 13 | |
| 14 | ## Prerequisites |
| 15 | |
| 16 | - Git installed |
| 17 | - Repository hosting (GitHub, GitLab, Bitbucket) |
| 18 | - Basic Git knowledge |
| 19 | |
| 20 | ## Branching Strategies |
| 21 | |
| 22 | ### Trunk-Based Development |
| 23 | |
| 24 | Best for: Continuous deployment, small teams, mature CI/CD |
| 25 | |
| 26 | ``` |
| 27 | main ─────●─────●─────●─────●─────●─────●─────● |
| 28 | │ │ │ │ │ │ |
| 29 | └─● └─● └─● └─● └─● └─● |
| 30 | feature branches (short-lived) |
| 31 | ``` |
| 32 | |
| 33 | ```bash |
| 34 | # Create short-lived feature branch |
| 35 | git checkout main |
| 36 | git pull origin main |
| 37 | git checkout -b feature/add-login |
| 38 | |
| 39 | # Work and commit frequently |
| 40 | git add . |
| 41 | git commit -m "feat: add login form" |
| 42 | |
| 43 | # Keep branch updated |
| 44 | git fetch origin |
| 45 | git rebase origin/main |
| 46 | |
| 47 | # Merge quickly (same day ideally) |
| 48 | git checkout main |
| 49 | git pull origin main |
| 50 | git merge feature/add-login |
| 51 | git push origin main |
| 52 | git branch -d feature/add-login |
| 53 | ``` |
| 54 | |
| 55 | ### GitHub Flow |
| 56 | |
| 57 | Best for: Continuous delivery, web applications |
| 58 | |
| 59 | ``` |
| 60 | main ─────●─────●───────────●─────────────●─────● |
| 61 | │ ↑ ↑ ↑ |
| 62 | └───●───●───┘ │ │ |
| 63 | feature/login │ │ |
| 64 | │ │ |
| 65 | └───●───●───●───●───────┘ │ |
| 66 | feature/dashboard │ |
| 67 | │ |
| 68 | └───●─────────────────────────┘ |
| 69 | hotfix/security-patch |
| 70 | ``` |
| 71 | |
| 72 | ```bash |
| 73 | # Create feature branch from main |
| 74 | git checkout main |
| 75 | git pull origin main |
| 76 | git checkout -b feature/user-dashboard |
| 77 | |
| 78 | # Push and create PR |
| 79 | git push -u origin feature/user-dashboard |
| 80 | |
| 81 | # After review, merge via PR (squash recommended) |
| 82 | # Delete branch after merge |
| 83 | ``` |
| 84 | |
| 85 | ### GitFlow |
| 86 | |
| 87 | Best for: Scheduled releases, versioned products |
| 88 | |
| 89 | ``` |
| 90 | main ────────●────────────────●──────────────● |
| 91 | ↑ ↑ ↑ |
| 92 | release ────────┼────●───●──────┼──────────────┼ |
| 93 | │ │ │ │ │ |
| 94 | develop ───●────●────┼───●──●───●───●───●───●──┼ |
| 95 | │ │ │ │ │ │ |
| 96 | feature ───┴─────────┘ │ │ │ │ |
| 97 | │ │ │ │ |
| 98 | hotfix ────────────────────┴───────┼───┼──────┘ |
| 99 | │ │ |
| 100 | feature ────────────────────────────┴───┘ |
| 101 | ``` |
| 102 | |
| 103 | ```bash |
| 104 | # Initialize GitFlow |
| 105 | git flow init |
| 106 | |
| 107 | # Start feature |
| 108 | git flow feature start user-auth |
| 109 | |
| 110 | # Finish feature (merges to develop) |
| 111 | git flow feature finish user-auth |
| 112 | |
| 113 | # Start release |
| 114 | git flow release start 1.0.0 |
| 115 | |
| 116 | # Finish release (merges to main and develop) |
| 117 | git flow release finish 1.0.0 |
| 118 | |
| 119 | # Hotfix |
| 120 | git flow hotfix start security-fix |
| 121 | git flow hotfix finish security-fix |
| 122 | ``` |
| 123 | |
| 124 | ## Commit Conventions |
| 125 | |
| 126 | ### Conventional Commits |
| 127 | |
| 128 | ``` |
| 129 | <type>(<scope>): <description> |
| 130 | |
| 131 | [optional body] |
| 132 | |
| 133 | [optional footer(s)] |
| 134 | ``` |
| 135 | |
| 136 | Types: |
| 137 | - `feat`: New feature |
| 138 | - `fix`: Bug fix |
| 139 | - `docs`: Documentation |
| 140 | - `style`: Formatting |
| 141 | - `refactor`: Code restructuring |
| 142 | - `test`: Adding tests |
| 143 | - `chore`: Maintenance |
| 144 | |
| 145 | Examples: |
| 146 | ```bash |
| 147 | git commit -m "feat(auth): add OAuth2 login support" |
| 148 | git commit -m "fix(api): handle null response from payment service" |
| 149 | git commit -m "docs: update API documentation for v2 endpoints" |
| 150 | git commit -m "refactor(db): optimize user query performance" |
| 151 | |
| 152 | # Breaking change |
| 153 | git commit -m "feat(api)!: change response format for user endpoint |
| 154 | |
| 155 | BREAKING CHANGE: The user endpoint now returns an object instead of array" |
| 156 | ``` |
| 157 | |
| 158 | ### Commit Message Template |
| 159 | |
| 160 | ```bash |
| 161 | # Create template file ~/.gitmessage |
| 162 | # Subject line (50 chars max) |
| 163 | |
| 164 | # Body (72 chars per line max) |
| 165 | # - What changed |
| 166 | # - Why it changed |
| 167 | # - Any side effects |
| 168 | |
| 169 | # Footer |
| 170 | # Fixes #123 |
| 171 | # Co-authored-by: Name <email> |
| 172 | |
| 173 | # Configure Git to use template |
| 174 | git config --global commit.template ~/.gitmessage |
| 175 | ``` |
| 176 | |
| 177 | ## Pull Request Workflow |
| 178 | |
| 179 | ### PR Template |
| 180 | |
| 181 | ```markdown |
| 182 | <!-- .github/pull_request_template.md --> |
| 183 | ## Description |
| 184 | Brief description of changes |
| 185 | |
| 186 | ## Type of Change |
| 187 | - [ ] Bug fix (non-breaking change) |
| 188 | - [ ] New feature (non-breaking change) |
| 189 | - [ ] Breaking change |
| 190 | - [ ] Documentation update |
| 191 | |
| 192 | ## Testing |
| 193 | - [ ] Unit tests added/updated |
| 194 | - [ ] Integration tests added/updated |
| 195 | - [ ] Manual testing performed |
| 196 | |
| 197 | ## Checklist |
| 198 | - [ ] Code follows project style guidelines |
| 199 | - [ ] Self-review performed |
| 200 | - [ ] Documentation updated |
| 201 | - [ ] No new warnings introduced |
| 202 | |
| 203 | ## Related Issues |
| 204 | Closes # |
| 205 | |
| 206 | ## Screenshots (if applicable) |
| 207 | ``` |
| 208 | |
| 209 | ### Branch Protection Rules |
| 210 | |
| 211 | ```yaml |
| 212 | # GitHu |