git switch docs

This newer command is marked as experimental (usage may change).

It does the same as a combination of git branch and git checkout.

Change branch

$ git switch BRANCH

Like

$ git branch BRANCH

Change and merge

If you have modified changes when you change, the CLI might give an error.

Then do a 3-way merge between your current branch and the target branch.

$ git switch -m BRANCH

And check changes with

$ git diff

Change to previous branch

$ git switch -

Like

$ git checkout -

Create branch and switch to it

Using --create.

$ git switch -c BRANCH

Equivalent to:

$ git branch BRANCH
$ git switch BRANCH

Or

$ git checkout -b BRANCH