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.

Category: Execution · Compare: git switch / Checkout Branch

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

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

ArgumentTypeRequiredWhat it is
branchstringyesBranch to switch to (or to create with create:true).
createbooleanCreate the branch first (git switch -c). Default false.
refstringCommit, tag or branch to create the new branch from (with create:true). Default: the current HEAD.