Create a Branch
Branch makes a new line of work. It starts at the snapshot you are on.
Create a branch
The new branch starts at the newest snapshot.
$ git branch add-recipe
$ git branchSwitch to the new branch
Creating did not switch. This step moves you onto it.
$ git switch add-recipeExample
$ git branch add-recipe
$ git branchKey points
- Branch with a name creates the branch.
- Creating a branch does not switch to it.
- Switch with -c creates the branch and switches in one step.
- Branch names use small words and dashes.
- A good name says what the branch is for.
- List the branches to check the new one exists.
Here, the new branch appears in the list. The star stays on main, because creating a branch does not switch to it.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
Which command creates a branch?