git-switch
Switch between branches
TLDR
Switch to branch
$ git switch [branch]
Create and switch$ git switch -c [new_branch]
Switch to previous branch$ git switch -
Create from specific commit$ git switch -c [branch] [commit]
Detach HEAD$ git switch --detach [commit]
Force switch$ git switch -f [branch]
Create orphan branch$ git switch --orphan [branch]
SYNOPSIS
git switch [options] branch
DESCRIPTION
git switch changes the current branch. Introduced in Git 2.23 to provide a focused command for branch switching, separating this concern from `git checkout` which also handles file restoration.Use `-c` to create a new branch and switch to it in one step, or `--detach` to move to a specific commit without being on any branch.
PARAMETERS
-c, --create branch
Create new branch.-C
Create or reset branch.-d, --detach
Detach HEAD.--orphan branch
Create orphan branch.-f, --force
Force switch.--guess
Guess remote branch.--no-guess
Don't guess remote.-t, --track
Set up tracking.
INSTALL
sudo apt install git
sudo dnf install git
sudo pacman -S git
sudo apk add git
sudo zypper install git
brew install git
nix profile install nixpkgs#git
CAVEATS
Was marked experimental for several releases after its introduction; behavior has since stabilized, but check `git switch --help` on older Git installs for differences.
SEE ALSO
git-checkout(1), git-branch(1)