Git Cheat Sheet/Switch branches

Switch to an existing branch.

Section: Branching and Switching

Switch branches

bash
bash
git switch main

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Branching and Switching
Create and switch branch
Create and switch in one step.
OpenIn sheetbashsame section
List all branches
Show local and remote-tracking branches.
OpenIn sheetbashsame section
List branches with last commit
Include tracking and latest commit info.
OpenIn sheetbashsame section
Create branch
Create a branch at current HEAD.
OpenIn sheetbashsame section
Rename current branch
Rename current branch.
OpenIn sheetbashsame section
Delete merged branch
Delete a merged local branch.
OpenIn sheetbashsame section