⌘K
git switch
all
Switch between Git branches. Requires Git version 2.23+. See also: `git checkout`.
More info →Options (3)
-c, --createbooleanCreate a new branch and switch to it
Example:
git switch {{[-c|--create]}} {{branch_name}}-m, --mergebooleanSwitch to a branch and automatically merge the current branch and any uncommitted changes into it
Example:
git switch {{[-m|--merge]}} {{branch_name}}-d, --detachbooleanSwitch to a tag
Example:
git switch {{[-d|--detach]}} {{tag}}Examples (7)
Switch to an existing branch
git switch branch_nameCreate a new branch and switch to it
git switch [-c|--create] branch_nameCreate a new branch based on an existing commit and switch to it
git switch [-c|--create] branch_name commitSwitch to the previous branch
git switch -Switch to a branch and update all submodules to match
git switch --recurse-submodules branch_nameSwitch to a branch and automatically merge the current branch and any uncommitted changes into it
git switch [-m|--merge] branch_nameSwitch to a tag
git switch [-d|--detach] tagmade by @shridhargupta | data from tldr-pages