Creating and Switching
Git branch and git switch.
Two commands do most of the work with branches. Git branch creates and lists them. Git switch moves you from one branch to another.

- git branch: create and list
- git switch: move between them
- That's most of it
Create, list, switch
Git branch on its own lists our branches. Just main, with a star, meaning we're on it. Now git branch dark creates a new branch. List again. Two branches, but the star is still on main. Creating a branch doesn't move you. To move, we type git switch dark. Git says switched to branch dark.
git branch * main git branch dark git branch dark * main git switch dark Switched to branch 'dark'
One step
Creating and switching is so common, there's a shortcut. Git switch, dash c, and a name. Dash c means create. It creates the branch and moves you onto it, in one step. Git status confirms we're on branch contact.
git switch -c contact Switched to a new branch 'contact' git status On branch contact nothing to commit, working tree clean
Summary
Git branch creates and lists branches. Git switch moves between them, and switch dash c does both at once. Next, how head follows you around.
Key takeaways- git branch <name>
- git switch <name>
- git switch -c <name>