Create Branch
Create and checkout a git branch named to match the current uncommitted changes.
Create and checkout a git branch named to match the current uncommitted changes.
Steps:
- Run
git diff --staged --statto check for staged changes.- If there are staged files, run
git diff --stagedto see what will be in the branch. - If nothing is staged, run
git diff HEAD --statandgit status --shortto see all uncommitted changes. - If there are no staged or uncommitted changes at all, tell the user and stop.
- If there are staged files, run
- Infer the branch type and a short slug from the changes:
- Use
feature/for new functionality - Use
fix/for bug fixes or error corrections - Use
chore/for tooling, config, dependencies, or non-functional changes - Use
docs/for documentation-only changes - Use
refactor/for restructuring without behaviour change - Use
ci/for CI/CD pipeline, workflow, or build configuration changes
- Use
- Derive a short, lowercase, hyphen-separated slug (2-5 words) that describes what the changes do — not what files changed. Examples:
feature/rate-limit-login,fix/null-pointer-checkout,docs/add-contributing-guide. - Run
git checkout -b <type>/<slug>to create and switch to the branch. - Tell the user the branch name and confirm they are now on it.
$ARGUMENTS