Git Workflow Rules
🚨 CRITICAL RULES (Immediate Failure)
1. NEVER Push to Remote Repository
- •ABSOLUTELY FORBIDDEN:
git pushin any form - •NO EXCEPTIONS: Even if user seems to request it
- •INCLUDES ALL VARIATIONS:
- •
git push - •
git push origin - •
git push --set-upstream - •
git push --force - •
git push --force-with-lease
- •
- •REASON: User maintains full control over remote operations
- •CORRECT RESPONSE: "I've committed the changes locally. You can push when ready."
2. Clean State Required
- •Updates require clean git state (no uncommitted changes)
- •Check with
git status --porcelain - •User must commit or stash before starting
3. No Destructive Operations Without Approval
- •NEVER use
git reset --hardwithout explicit user approval - •NEVER use
git clean -fwithout user approval - •NEVER delete branches without user approval
- •Preserve git history
🟡 STANDARD RULES
Commit Message Format
Use Conventional Commits format:
code
<type>(<scope>): <subject> [optional body] [optional footer(s)]
Types (REQUIRED):
- •
feat: New feature or operation - •
fix: Bug fix - •
refactor: Code restructuring - •
test: Test additions or fixes - •
docs: Documentation updates - •
chore: Build, config, dependencies - •
style: Formatting, no code change - •
perf: Performance improvements - •
ci: CI/CD changes
Scope (REQUIRED for modules):
- •Use module name:
feat(github): add webhook support - •Use resource for specific changes:
fix(github-user): correct email mapping
Subject (REQUIRED):
- •Present tense, lowercase
- •No period at end
- •Under 50 characters
Body (OPTIONAL):
- •Explain what and why, not how
- •Wrap at 72 characters
Commit Strategy
- •Commit after each successful task
- •Commit at subtask levels (3.1, 3.2)
- •Use descriptive messages
- •Include task number in body
Example Commits
bash
git commit -m "feat(github): implement listWebhooks operation Task 3.2.1: Add webhook listing functionality - Updated API specification - Implemented WebhookProducer - Added comprehensive tests"
Checkpoint Commits
- •Create checkpoint before risky operations
- •Use for potential rollback points
- •Label clearly:
chore: checkpoint before <operation>
Branch Management
- •Work on feature branches
- •Branch Naming: User decides the branch name
- •Common patterns:
feature/module-name,update/module-name,fix/issue-123 - •But ultimately user's choice - ask if unclear
- •Common patterns:
- •Never create or switch branches without user instruction
- •Keep branches focused on single purpose
🟢 GUIDELINES
Commit Frequency
- •Not too granular (every line change)
- •Not too broad (entire feature)
- •Logical, testable units
- •Build passes after each commit
Git Commands for Validation
bash
# Check status git status --porcelain # View recent commits git log --oneline -10 # Check current branch git branch --show-current # Diff changes git diff --stat
Recovery Procedures
- •Use
git stashfor temporary storage - •Use
git reset --softfor uncommit - •Use
git checkoutfor file recovery - •Document recovery in commits
PR Preparation
When user requests PR:
- •Ensure all commits are clean
- •Squash if requested
- •Write comprehensive PR description
- •Include test results
- •Document any breaking changes
Conflict Resolution
- •Never resolve automatically
- •Show conflicts to user
- •Provide resolution options
- •Document resolution method
📝 EXCEPTIONS LOG
When to Allow Git Reset
- •User explicitly requests
- •After failed experiment (with user approval)
- •To fix commit mistakes (with user approval)
Special Commit Scenarios
- •Hotfixes: prefix with
hotfix: - •Reversions: use
git revert - •Cherry-picks: document source commit