|
| 1 | +# Git Branching Workflow Extension |
| 2 | + |
| 3 | +Feature branch creation, numbering (sequential/timestamp), validation, and Git remote detection for Spec Kit. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This extension provides Git branching operations as an optional, self-contained module. It manages: |
| 8 | + |
| 9 | +- **Feature branch creation** with sequential (`001-feature-name`) or timestamp (`20260319-143022-feature-name`) numbering |
| 10 | +- **Branch validation** to ensure branches follow naming conventions |
| 11 | +- **Git remote detection** for GitHub integration (e.g., issue creation) |
| 12 | + |
| 13 | +## Commands |
| 14 | + |
| 15 | +| Command | Description | |
| 16 | +|---------|-------------| |
| 17 | +| `speckit.git.feature` | Create a feature branch with sequential or timestamp numbering | |
| 18 | +| `speckit.git.validate` | Validate current branch follows feature branch naming conventions | |
| 19 | +| `speckit.git.remote` | Detect Git remote URL for GitHub integration | |
| 20 | + |
| 21 | +## Hooks |
| 22 | + |
| 23 | +| Event | Command | Optional | Description | |
| 24 | +|-------|---------|----------|-------------| |
| 25 | +| `before_specify` | `speckit.git.feature` | No | Create feature branch before specification | |
| 26 | +| `after_implement` | `speckit.git.validate` | Yes | Validate branch naming after implementation | |
| 27 | + |
| 28 | +## Configuration |
| 29 | + |
| 30 | +Configuration is stored in `.specify/extensions/git/git-config.yml`: |
| 31 | + |
| 32 | +```yaml |
| 33 | +# Branch numbering strategy: "sequential" or "timestamp" |
| 34 | +branch_numbering: sequential |
| 35 | + |
| 36 | +# Branch name template |
| 37 | +branch_template: "{number}-{short_name}" |
| 38 | + |
| 39 | +# Whether to fetch remotes before computing next branch number |
| 40 | +auto_fetch: true |
| 41 | +``` |
| 42 | +
|
| 43 | +### Environment Variable Override |
| 44 | +
|
| 45 | +Set `SPECKIT_GIT_BRANCH_NUMBERING` to override the `branch_numbering` config value: |
| 46 | + |
| 47 | +```bash |
| 48 | +export SPECKIT_GIT_BRANCH_NUMBERING=timestamp |
| 49 | +``` |
| 50 | + |
| 51 | +## Installation |
| 52 | + |
| 53 | +```bash |
| 54 | +# Install from the bundled extension |
| 55 | +specify extension add git --from extensions/git/ |
| 56 | +
|
| 57 | +# Or it auto-installs during specify init (migration period) |
| 58 | +``` |
| 59 | + |
| 60 | +## Disabling |
| 61 | + |
| 62 | +```bash |
| 63 | +# Disable the git extension (spec creation continues without branching) |
| 64 | +specify extension disable git |
| 65 | +
|
| 66 | +# Re-enable it |
| 67 | +specify extension enable git |
| 68 | +``` |
| 69 | + |
| 70 | +## Graceful Degradation |
| 71 | + |
| 72 | +When Git is not installed or the directory is not a Git repository: |
| 73 | +- Spec directories are still created under `specs/` |
| 74 | +- Branch creation is skipped with a warning |
| 75 | +- Branch validation is skipped with a warning |
| 76 | +- Remote detection returns empty results |
| 77 | + |
| 78 | +## Scripts |
| 79 | + |
| 80 | +The extension bundles cross-platform scripts: |
| 81 | + |
| 82 | +- `scripts/bash/create-new-feature.sh` — Bash implementation |
| 83 | +- `scripts/bash/git-common.sh` — Shared Git utilities (Bash) |
| 84 | +- `scripts/powershell/create-new-feature.ps1` — PowerShell implementation |
| 85 | +- `scripts/powershell/git-common.ps1` — Shared Git utilities (PowerShell) |
0 commit comments