|
| 1 | +# Git Flow Workflow |
| 2 | + |
| 3 | +## Branch Structure |
| 4 | + |
| 5 | +``` |
| 6 | +main (production) |
| 7 | + └── develop (integration) |
| 8 | + ├── feature/* (new features) |
| 9 | + ├── bugfix/* (bug fixes) |
| 10 | + ├── hotfix/* (production fixes) |
| 11 | + └── release/* (release preparation) |
| 12 | +``` |
| 13 | + |
| 14 | +## Branch Descriptions |
| 15 | + |
| 16 | +### Main Branches |
| 17 | + |
| 18 | +- **main**: Production-ready code only. All commits are tagged releases. |
| 19 | +- **develop**: Integration branch for features. Always reflects latest delivered development changes. |
| 20 | + |
| 21 | +### Supporting Branches |
| 22 | + |
| 23 | +- **feature/**: New features branching from `develop` |
| 24 | +- **bugfix/**: Bug fixes for `develop` |
| 25 | +- **hotfix/**: Critical production fixes from `main` |
| 26 | +- **release/**: Release preparation from `develop` |
| 27 | + |
| 28 | +## Workflow |
| 29 | + |
| 30 | +### Starting a New Feature |
| 31 | + |
| 32 | +```bash |
| 33 | +git checkout develop |
| 34 | +git pull origin develop |
| 35 | +git checkout -b feature/your-feature-name |
| 36 | +``` |
| 37 | + |
| 38 | +### Working on a Feature |
| 39 | + |
| 40 | +```bash |
| 41 | +# Make changes |
| 42 | +git add . |
| 43 | +git commit -m "feat: implement feature X" |
| 44 | + |
| 45 | +# Push to remote |
| 46 | +git push -u origin feature/your-feature-name |
| 47 | +``` |
| 48 | + |
| 49 | +### Finishing a Feature |
| 50 | + |
| 51 | +```bash |
| 52 | +# Update develop |
| 53 | +git checkout develop |
| 54 | +git pull origin develop |
| 55 | + |
| 56 | +# Merge feature |
| 57 | +git merge --no-ff feature/your-feature-name -m "Merge feature/your-feature-name" |
| 58 | + |
| 59 | +# Push |
| 60 | +git push origin develop |
| 61 | + |
| 62 | +# Delete feature branch |
| 63 | +git branch -d feature/your-feature-name |
| 64 | +git push origin --delete feature/your-feature-name |
| 65 | +``` |
| 66 | + |
| 67 | +### Creating a Release |
| 68 | + |
| 69 | +```bash |
| 70 | +# Start release from develop |
| 71 | +git checkout develop |
| 72 | +git pull origin develop |
| 73 | +git checkout -b release/v0.2.0 |
| 74 | + |
| 75 | +# Update version numbers, changelog, etc. |
| 76 | +npm version minor # or patch, major |
| 77 | + |
| 78 | +# Commit version bump |
| 79 | +git commit -am "chore: bump version to 0.2.0" |
| 80 | + |
| 81 | +# Merge to main |
| 82 | +git checkout main |
| 83 | +git merge --no-ff release/v0.2.0 -m "Release v0.2.0" |
| 84 | +git tag -a v0.2.0 -m "Release version 0.2.0" |
| 85 | + |
| 86 | +# Merge back to develop |
| 87 | +git checkout develop |
| 88 | +git merge --no-ff release/v0.2.0 -m "Merge release v0.2.0 back to develop" |
| 89 | + |
| 90 | +# Push everything |
| 91 | +git push origin main --tags |
| 92 | +git push origin develop |
| 93 | + |
| 94 | +# Delete release branch |
| 95 | +git branch -d release/v0.2.0 |
| 96 | +git push origin --delete release/v0.2.0 |
| 97 | +``` |
| 98 | + |
| 99 | +### Hotfix Workflow |
| 100 | + |
| 101 | +```bash |
| 102 | +# Start hotfix from main |
| 103 | +git checkout main |
| 104 | +git pull origin main |
| 105 | +git checkout -b hotfix/critical-bug |
| 106 | + |
| 107 | +# Fix and commit |
| 108 | +git commit -am "fix: resolve critical production bug" |
| 109 | + |
| 110 | +# Bump patch version |
| 111 | +npm version patch |
| 112 | + |
| 113 | +# Merge to main |
| 114 | +git checkout main |
| 115 | +git merge --no-ff hotfix/critical-bug |
| 116 | +git tag -a v0.1.1 -m "Hotfix v0.1.1" |
| 117 | + |
| 118 | +# Merge to develop |
| 119 | +git checkout develop |
| 120 | +git merge --no-ff hotfix/critical-bug |
| 121 | + |
| 122 | +# Push |
| 123 | +git push origin main --tags |
| 124 | +git push origin develop |
| 125 | + |
| 126 | +# Delete hotfix branch |
| 127 | +git branch -d hotfix/critical-bug |
| 128 | +git push origin --delete hotfix/critical-bug |
| 129 | +``` |
| 130 | + |
| 131 | +## Commit Message Convention |
| 132 | + |
| 133 | +Follow [Conventional Commits](https://www.conventionalcommits.org/): |
| 134 | + |
| 135 | +``` |
| 136 | +<type>(<scope>): <subject> |
| 137 | +
|
| 138 | +<body> |
| 139 | +
|
| 140 | +<footer> |
| 141 | +``` |
| 142 | + |
| 143 | +### Types |
| 144 | + |
| 145 | +- **feat**: New feature |
| 146 | +- **fix**: Bug fix |
| 147 | +- **docs**: Documentation only |
| 148 | +- **style**: Code style changes (formatting, etc.) |
| 149 | +- **refactor**: Code refactoring |
| 150 | +- **perf**: Performance improvements |
| 151 | +- **test**: Adding or updating tests |
| 152 | +- **build**: Build system changes |
| 153 | +- **ci**: CI/CD changes |
| 154 | +- **chore**: Other changes (dependencies, etc.) |
| 155 | + |
| 156 | +### Examples |
| 157 | + |
| 158 | +```bash |
| 159 | +git commit -m "feat(auth): add JWT token refresh mechanism" |
| 160 | +git commit -m "fix(executor): resolve statement execution bug" |
| 161 | +git commit -m "test(mcp): add aggregator connection tests" |
| 162 | +git commit -m "docs(readme): update installation instructions" |
| 163 | +``` |
| 164 | + |
| 165 | +## Worktrees for Parallel Development |
| 166 | + |
| 167 | +### Setting Up Worktrees |
| 168 | + |
| 169 | +```bash |
| 170 | +# Create worktree for feature development |
| 171 | +git worktree add ../codemode-feature-auth feature/auth-improvements |
| 172 | + |
| 173 | +# Work in the worktree |
| 174 | +cd ../codemode-feature-auth |
| 175 | +# Make changes, commit, etc. |
| 176 | + |
| 177 | +# When done, remove worktree |
| 178 | +git worktree remove ../codemode-feature-auth |
| 179 | +``` |
| 180 | + |
| 181 | +### Benefits of Worktrees |
| 182 | + |
| 183 | +- Work on multiple features simultaneously without switching branches |
| 184 | +- Keep builds/node_modules separate per branch |
| 185 | +- Test integration without stashing changes |
| 186 | + |
| 187 | +### Common Worktree Commands |
| 188 | + |
| 189 | +```bash |
| 190 | +# List all worktrees |
| 191 | +git worktree list |
| 192 | + |
| 193 | +# Add new worktree |
| 194 | +git worktree add <path> <branch> |
| 195 | + |
| 196 | +# Remove worktree |
| 197 | +git worktree remove <path> |
| 198 | + |
| 199 | +# Prune deleted worktrees |
| 200 | +git worktree prune |
| 201 | +``` |
| 202 | + |
| 203 | +## CI/CD Integration |
| 204 | + |
| 205 | +- **Pull Requests**: Must pass all tests before merging |
| 206 | +- **Develop**: Continuous integration testing |
| 207 | +- **Main**: Production deployment triggered on merge |
| 208 | +- **Release Tags**: Automated deployment to production |
| 209 | + |
| 210 | +## Branch Protection Rules |
| 211 | + |
| 212 | +### Main Branch |
| 213 | + |
| 214 | +- Require pull request reviews |
| 215 | +- Require status checks to pass |
| 216 | +- Require branches to be up to date |
| 217 | +- No force pushes |
| 218 | +- No deletions |
| 219 | + |
| 220 | +### Develop Branch |
| 221 | + |
| 222 | +- Require status checks to pass |
| 223 | +- Allow force pushes by administrators only |
| 224 | + |
| 225 | +## Quick Reference |
| 226 | + |
| 227 | +```bash |
| 228 | +# Update all branches |
| 229 | +git checkout main && git pull |
| 230 | +git checkout develop && git pull |
| 231 | + |
| 232 | +# Clean up merged branches |
| 233 | +git branch --merged | grep -v "\*\|main\|develop" | xargs -n 1 git branch -d |
| 234 | + |
| 235 | +# Sync develop with main |
| 236 | +git checkout develop |
| 237 | +git merge main |
| 238 | +git push origin develop |
| 239 | +``` |
| 240 | + |
| 241 | +## Current Project Status |
| 242 | + |
| 243 | +- **Main**: Production-ready code with 170 unit tests |
| 244 | +- **Develop**: Integration branch for new features |
| 245 | +- **Active Features**: None currently |
| 246 | +- **Latest Release**: v0.1.0 (initial test suite) |
0 commit comments