Description
With no arguments, lists your local branches and marks the current one with *.
With a name, creates a branch at the current commit. It doesn't switch to the new branch; use grit switch -c to create a branch and switch to it in one step.
Branch names follow the same rules as git check-ref-format --branch (no spaces, .., ~, .lock, reserved names like HEAD, and other characters Git rejects). Invalid names fail before anything is written under .git/refs.
With -d, deletes a branch. grit refuses if the branch has commits that aren't in the current branch, so you can't lose work by accident; -D deletes it anyway. You can't delete the branch you're on.
Options
| Option | Description |
|---|---|
<name> |
The branch to create or delete. Omit to list branches. |
-d, --delete |
Delete the branch. It must be fully merged into the current branch. |
-D, --force |
Delete the branch even if it isn't merged. |
JSON output
Pass --json for stable, scripting-friendly output. The object's action field says what happened:
| Field | Type | Meaning |
|---|---|---|
action |
string | list, create, or delete. |
current |
string or null | For list, the current branch, or null when detached. |
branches |
array | For list, each branch with name and current. |
name |
string | For create or delete, the branch name. |
oid |
string | For delete, full id of the tip before deletion. |
short_oid |
string | For delete, abbreviated tip id. |