$npx -y skills add sabahattink/antigravity-fullstack-hq --skill git-workflowGit branching strategy, commit messages, PR workflow, conflict resolution. Use when setting up a branching strategy, writing commit messages, creating pull requests, or resolving merge conflicts.
| 1 | # Git Workflow |
| 2 | |
| 3 | ## Branching Strategy (GitHub Flow) |
| 4 | |
| 5 | ``` |
| 6 | main ← production-ready at all times |
| 7 | └── feature/add-user-export ← feature branches (short-lived) |
| 8 | └── fix/login-rate-limit ← bug fix branches |
| 9 | └── chore/upgrade-dependencies ← maintenance |
| 10 | └── refactor/extract-auth-module ← refactoring |
| 11 | ``` |
| 12 | |
| 13 | **Rules:** |
| 14 | - `main` is protected — no direct pushes |
| 15 | - Every change goes through a PR |
| 16 | - PRs require at least 1 approval |
| 17 | - CI must pass before merge |
| 18 | - Branches are deleted after merge |
| 19 | |
| 20 | ## Branch Naming |
| 21 | |
| 22 | ```bash |
| 23 | # Pattern: <type>/<short-description> |
| 24 | feature/user-profile-page |
| 25 | feature/export-orders-xlsx |
| 26 | fix/refresh-token-cookie-samesite |
| 27 | fix/n-plus-one-users-query |
| 28 | chore/update-nestjs-10 |
| 29 | refactor/extract-payment-service |
| 30 | docs/add-api-endpoints-readme |
| 31 | test/add-auth-integration-tests |
| 32 | release/v2.1.0 |
| 33 | |
| 34 | # DO NOT use: |
| 35 | johns-branch # ← no name, no context |
| 36 | fix1 # ← too vague |
| 37 | JIRA-1234 # ← jira IDs alone mean nothing |
| 38 | wip # ← push to a real branch when ready |
| 39 | ``` |
| 40 | |
| 41 | ## Commit Messages |
| 42 | |
| 43 | ``` |
| 44 | <type>(<scope>): <short description> |
| 45 | |
| 46 | <optional body — wrap at 72 chars> |
| 47 | |
| 48 | <optional footer: BREAKING CHANGE or fixes #issue> |
| 49 | ``` |
| 50 | |
| 51 | **Types:** |
| 52 | ``` |
| 53 | feat — new feature |
| 54 | fix — bug fix |
| 55 | refactor — code change that neither fixes a bug nor adds a feature |
| 56 | perf — performance improvement |
| 57 | test — adding or correcting tests |
| 58 | docs — documentation only |
| 59 | chore — build process, tooling, dependencies |
| 60 | ci — CI/CD config changes |
| 61 | ``` |
| 62 | |
| 63 | **Examples:** |
| 64 | ```bash |
| 65 | # Good |
| 66 | git commit -m "feat(auth): add JWT refresh token rotation" |
| 67 | git commit -m "fix(users): prevent email enumeration on login" |
| 68 | git commit -m "refactor(orders): extract payment processing to dedicated service" |
| 69 | git commit -m "perf(queries): add index on orders.user_id column" |
| 70 | git commit -m "test(auth): add integration tests for token expiry flow" |
| 71 | |
| 72 | # With body |
| 73 | git commit -m "fix(uploads): reject files larger than 5MB |
| 74 | |
| 75 | Previously the file size limit was only enforced on the frontend. |
| 76 | An attacker could bypass this by posting directly to the API. |
| 77 | Added multer limits and a guard to enforce 5MB server-side. |
| 78 | |
| 79 | Fixes #142" |
| 80 | |
| 81 | # Bad |
| 82 | git commit -m "fix bug" # ← no context |
| 83 | git commit -m "WIP" # ← push to a real WIP branch |
| 84 | git commit -m "asdfgh" # ← meaningless |
| 85 | git commit -m "changes" # ← what changes? |
| 86 | ``` |
| 87 | |
| 88 | ## Creating a PR |
| 89 | |
| 90 | ```bash |
| 91 | # 1. Create branch from main |
| 92 | git checkout main |
| 93 | git pull origin main |
| 94 | git checkout -b feature/user-export |
| 95 | |
| 96 | # 2. Make changes, commit incrementally |
| 97 | git add src/users/users.service.ts src/users/dto/export.dto.ts |
| 98 | git commit -m "feat(users): add CSV export endpoint" |
| 99 | |
| 100 | git add src/users/users.service.spec.ts |
| 101 | git commit -m "test(users): add unit tests for CSV export" |
| 102 | |
| 103 | # 3. Push and create PR |
| 104 | git push -u origin feature/user-export |
| 105 | gh pr create \ |
| 106 | --title "feat(users): add CSV export endpoint" \ |
| 107 | --body "$(cat <<'EOF' |
| 108 | ## What |
| 109 | Adds a new endpoint GET /users/export.csv that returns all users as CSV. |
| 110 | |
| 111 | ## Why |
| 112 | Requested by ops team for bulk user management workflows. Fixes #89. |
| 113 | |
| 114 | ## Testing |
| 115 | - [ ] Unit tests added (users.service.spec.ts) |
| 116 | - [ ] Tested locally with 10k users |
| 117 | - [ ] Response headers verified in browser download |
| 118 | |
| 119 | ## Breaking Changes |
| 120 | None — new endpoint only. |
| 121 | EOF |
| 122 | )" |
| 123 | ``` |
| 124 | |
| 125 | ## Keeping Your Branch Updated |
| 126 | |
| 127 | ```bash |
| 128 | # Rebase onto main (preferred — keeps history linear) |
| 129 | git fetch origin |
| 130 | git rebase origin/main |
| 131 | |
| 132 | # If conflicts: |
| 133 | # 1. Open conflicted files, resolve |
| 134 | # 2. git add <resolved-files> |
| 135 | # 3. git rebase --continue |
| 136 | # If in trouble: git rebase --abort |
| 137 | |
| 138 | # Merge main into branch (alternative — creates merge commit) |
| 139 | git merge origin/main |
| 140 | ``` |
| 141 | |
| 142 | ## Resolving Merge Conflicts |
| 143 | |
| 144 | ```bash |
| 145 | # See what's conflicting |
| 146 | git status |
| 147 | |
| 148 | # Open in VS Code |
| 149 | code . |
| 150 | |
| 151 | # After resolving, mark as done |
| 152 | git add src/users/users.service.ts |
| 153 | |
| 154 | # Continue rebase |
| 155 | git rebase --continue |
| 156 | # OR complete merge commit |
| 157 | git commit |
| 158 | ``` |
| 159 | |
| 160 | **Conflict marker anatomy:** |
| 161 | ```typescript |
| 162 | <<<<<<< HEAD (your branch) |
| 163 | function getUserById(id: string) { |
| 164 | return this.repo.findOne({ where: { id } }) |
| 165 | ======= |
| 166 | async function getUserById(id: number) { |
| 167 | return this.repo.findOne({ where: { id }, relations: ['profile'] }) |
| 168 | >>>>>>> origin/main |
| 169 | |
| 170 | // Resolve: pick the right version or combine both intentions |
| 171 | async function getUserById(id: string) { |
| 172 | return this.repo.findOne({ where: { id }, relations: ['profile'] }) |
| 173 | } |
| 174 | ``` |
| 175 | |
| 176 | ## Git Commands Reference |
| 177 | |
| 178 | ```bash |
| 179 | # Status |
| 180 | git status |
| 181 | git diff # unstaged changes |
| 182 | git diff --staged # staged changes |
| 183 | git log --oneline -10 # last 10 commits |
| 184 | git log --graph --oneline # visual branch tree |
| 185 | |
| 186 | # Staging |
| 187 | git add <file> # stage specific file |
| 188 | git add -p # interactive staging — review hunks |
| 189 | git reset HEAD <fil |