ek9_git_switch
Reports status (switched or created), branch and previousBranch; a dirty tree that would be overwritten is refused with the route (commit, stash or restore first), never auto-stashed.
When to use it
'Switch to branch X' or 'start a branch for this work' - one call with branch; create:true creates it from HEAD (or ref) and switches. Branch here BEFORE committing onto the default branch.
When not to use it
- listing the branches that exist - use
ek9_git_branch. - unstaging or discarding file changes - use
ek9_git_restore. - parking uncommitted changes so a switch can proceed - use
ek9_git_stash. - recording changes on the current branch - use
ek9_git_commit.
Details
Uses git switch (never checkout, which can silently discard working-tree changes). ref is only meaningful with create:true. No auto-stash: a dirty tree that would be overwritten is refused as dirty-tree with the route (commit, stash or restore first); branch-not-found and already-exists are refused with theirs.
Arguments
| Argument | Type | Required | What it is |
|---|---|---|---|
branch | string | yes | Branch to switch to (or to create with create:true). |
create | boolean | Create the branch first (git switch -c). Default false. | |
ref | string | Commit, tag or branch to create the new branch from (with create:true). Default: the current HEAD. |