--- name: git-workflow description: Git best practices, branching strategies, commit conventions, and PR workflows. Use when reviewing git history, writing commits, setting up branching strategy, or improving git practices. Triggers on "git best practices", "commit message", "branching strategy", or "PR workflow". license: MIT metadata: author: AsyrafHussin version: "1.2.0" --- # Git Workflow Git best practices, commit conventions, branching strategies, and pull request workflows. Guidelines for maintaining a clean, useful git history. ## When to Apply Reference these guidelines when: - Writing commit messages - Creating branches - Setting up git workflows - Reviewing pull requests - Maintaining git history ## Rule Categories by Priority | Priority | Category | Impact | Prefix | |----------|----------|--------|--------| | 1 | Commit Messages | CRITICAL | `commit-` | | 2 | Branching Strategy | HIGH | `branch-` | | 3 | Pull Requests | HIGH | `pr-` | | 4 | History Management | MEDIUM | `history-` | | 5 | Collaboration | MEDIUM | `collab-` | ## Quick Reference ### 1. Commit Messages (CRITICAL) - `commit-conventional` - Use conventional commits - `commit-atomic` - Atomic commits (one logical change) - `commit-present-tense` - Use imperative present tense - `commit-meaningful` - Descriptive, meaningful messages - `commit-body` - Add body for complex changes - `commit-references` - Reference issues/tickets - `commit-git-hooks` - Enforce standards with Husky + commitlint ### 2. Branching Strategy (HIGH) - `branch-naming` - Consistent branch naming - `branch-feature` - Feature branch workflow - `branch-main-protected` - Protect main branch - `branch-short-lived` - Keep branches short-lived - `branch-delete-merged` - Delete merged branches - `branch-release` - Release branch strategy - `branch-workflow-strategies` - GitFlow vs GitHub Flow vs Trunk-Based - `branch-monorepo` - Monorepo git workflows ### 3. Pull Requests (HIGH) - `pr-small` - Keep PRs small and focused - `pr-description` - Write clear descriptions - `pr-reviewers` - Request appropriate reviewers - `pr-ci-pass` - Ensure CI passes - `pr-squash` - Squash when appropriate - `pr-draft` - Use draft PRs for WIP and early feedback ### 4. History Management (MEDIUM) - `history-rebase` - Rebase vs merge - `history-no-force-push` - Avoid force push to shared branches - `history-clean` - Keep history clean - `history-tags` - Use tags for releases - `history-worktree` - Work on multiple branches with git worktree ### 5. Collaboration (MEDIUM) - `collab-code-review` - Effective code reviews - `collab-conflicts` - Handle merge conflicts - `collab-communication` - Communicate changes - `collab-gitignore` - .gitignore best practices ## Essential Guidelines ### Conventional Commits ``` # Format ():