|
| 1 | +# Git Branching Workflow Extension |
| 2 | + |
| 3 | +Git repository initialization, feature branch creation, numbering (sequential/timestamp), validation, remote detection, and auto-commit for Spec Kit. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This extension provides Git operations as an optional, self-contained module. It manages: |
| 8 | + |
| 9 | +- **Repository initialization** with configurable commit messages |
| 10 | +- **Feature branch creation** with sequential (`001-feature-name`) or timestamp (`20260319-143022-feature-name`) numbering |
| 11 | +- **Branch validation** to ensure branches follow naming conventions |
| 12 | +- **Git remote detection** for GitHub integration (e.g., issue creation) |
| 13 | +- **Auto-commit** after core commands (configurable per-command with custom messages) |
| 14 | + |
| 15 | +## Commands |
| 16 | + |
| 17 | +| Command | Description | |
| 18 | +|---------|-------------| |
| 19 | +| `speckit.git.initialize` | Initialize a Git repository with a configurable commit message | |
| 20 | +| `speckit.git.feature` | Create a feature branch with sequential or timestamp numbering | |
| 21 | +| `speckit.git.validate` | Validate current branch follows feature branch naming conventions | |
| 22 | +| `speckit.git.remote` | Detect Git remote URL for GitHub integration | |
| 23 | +| `speckit.git.commit` | Auto-commit changes (configurable per-command enable/disable and messages) | |
| 24 | + |
| 25 | +## Hooks |
| 26 | + |
| 27 | +| Event | Command | Optional | Description | |
| 28 | +|-------|---------|----------|-------------| |
| 29 | +| `before_constitution` | `speckit.git.initialize` | No | Init git repo before constitution | |
| 30 | +| `before_specify` | `speckit.git.feature` | No | Create feature branch before specification | |
| 31 | +| `before_clarify` | `speckit.git.commit` | Yes | Commit outstanding changes before clarification | |
| 32 | +| `before_plan` | `speckit.git.commit` | Yes | Commit outstanding changes before planning | |
| 33 | +| `before_tasks` | `speckit.git.commit` | Yes | Commit outstanding changes before task generation | |
| 34 | +| `before_implement` | `speckit.git.commit` | Yes | Commit outstanding changes before implementation | |
| 35 | +| `before_checklist` | `speckit.git.commit` | Yes | Commit outstanding changes before checklist | |
| 36 | +| `before_analyze` | `speckit.git.commit` | Yes | Commit outstanding changes before analysis | |
| 37 | +| `before_taskstoissues` | `speckit.git.commit` | Yes | Commit outstanding changes before issue sync | |
| 38 | +| `after_constitution` | `speckit.git.commit` | Yes | Auto-commit after constitution update | |
| 39 | +| `after_specify` | `speckit.git.commit` | Yes | Auto-commit after specification | |
| 40 | +| `after_clarify` | `speckit.git.commit` | Yes | Auto-commit after clarification | |
| 41 | +| `after_plan` | `speckit.git.commit` | Yes | Auto-commit after planning | |
| 42 | +| `after_tasks` | `speckit.git.commit` | Yes | Auto-commit after task generation | |
| 43 | +| `after_implement` | `speckit.git.commit` | Yes | Auto-commit after implementation | |
| 44 | +| `after_checklist` | `speckit.git.commit` | Yes | Auto-commit after checklist | |
| 45 | +| `after_analyze` | `speckit.git.commit` | Yes | Auto-commit after analysis | |
| 46 | +| `after_taskstoissues` | `speckit.git.commit` | Yes | Auto-commit after issue sync | |
| 47 | + |
| 48 | +## Configuration |
| 49 | + |
| 50 | +Configuration is stored in `.specify/extensions/git/git-config.yml`: |
| 51 | + |
| 52 | +```yaml |
| 53 | +# Branch numbering strategy: "sequential" or "timestamp" |
| 54 | +branch_numbering: sequential |
| 55 | + |
| 56 | +# Custom commit message for git init |
| 57 | +init_commit_message: "[Spec Kit] Initial commit" |
| 58 | + |
| 59 | +# Auto-commit per command (all disabled by default) |
| 60 | +# Example: enable auto-commit after specify |
| 61 | +auto_commit: |
| 62 | + default: false |
| 63 | + after_specify: |
| 64 | + enabled: true |
| 65 | + message: "[Spec Kit] Add specification" |
| 66 | +``` |
| 67 | +
|
| 68 | +## Installation |
| 69 | +
|
| 70 | +```bash |
| 71 | +# Install the bundled git extension (no network required) |
| 72 | +specify extension add git |
| 73 | +``` |
| 74 | + |
| 75 | +## Disabling |
| 76 | + |
| 77 | +```bash |
| 78 | +# Disable the git extension (spec creation continues without branching) |
| 79 | +specify extension disable git |
| 80 | + |
| 81 | +# Re-enable it |
| 82 | +specify extension enable git |
| 83 | +``` |
| 84 | + |
| 85 | +## Graceful Degradation |
| 86 | + |
| 87 | +When Git is not installed or the directory is not a Git repository: |
| 88 | +- Spec directories are still created under `specs/` |
| 89 | +- Branch creation is skipped with a warning |
| 90 | +- Branch validation is skipped with a warning |
| 91 | +- Remote detection returns empty results |
| 92 | + |
| 93 | +## Scripts |
| 94 | + |
| 95 | +The extension bundles cross-platform scripts: |
| 96 | + |
| 97 | +- `scripts/bash/create-new-feature.sh` — Bash implementation |
| 98 | +- `scripts/bash/git-common.sh` — Shared Git utilities (Bash) |
| 99 | +- `scripts/powershell/create-new-feature.ps1` — PowerShell implementation |
| 100 | +- `scripts/powershell/git-common.ps1` — Shared Git utilities (PowerShell) |
0 commit comments