Switch Branch
git switch <branch>Switches to an existing branch.
Tip: Older equivalent: git checkout <branch>.
To switch to an existing Git branch, run git switch <branch>. For example, git switch feature-login selects the existing feature-login branch; replace that example name with your branch name.
git switch <branch>git switch <branch>Switches to an existing branch.
Tip: Older equivalent: git checkout <branch>.
Tip: Older equivalent: git checkout <branch>.
Git switches to the selected branch and updates the index (staging area) and working tree to match it. New commits you create are added to that branch. The command does not create a new branch; use the separate create-and-switch command when that is your task.
Git does not require a completely clean index and working tree before switching. It normally refuses the operation if switching would lose local changes. Read the refusal and review your changes before deciding whether to commit or stash them. Do not add --discard-changes just to bypass the refusal: that option discards local changes.
List your branches before choosing one, create a branch when it does not exist yet, or review how to stash work before switching.
Run git switch <branch>.
Run git switch <branch>.
Type it in the terminal or command-line interface used by Git.
Yes. The command text is the same on both platforms when the tool is installed.