git switch Move to another branch

Changes the branch you are working on, updating your files to match. It is a clearer, safer replacement for the branch-switching part of git checkout.

Synopsis

git switch [OPTION]... BRANCH
git switch -c NEW-BRANCH [START-POINT]

Common options

Option or formWhat it does
-c NAMECreate a new branch and switch to it
-Switch back to the previous branch
-d, --detachCheck out a commit without a branch, to look around
--trackWhen switching to a remote branch, set up tracking
-f, --discard-changesThrow away local changes to switch

Examples

Switch to an existing branch
git switch main
Switched to branch 'main'
Create a branch and start working
git switch -c feature/search
Create a branch from a tag
git switch -c hotfix v1.2.0
Go back to where you just were
git switch -
Work on a branch that exists on origin
git switch feature/login

Notes

See also

Last reviewed 2026-10-09.