

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: What Is a Branch?
incomplete
2: Default Branch
incomplete
3: Visualizing Branches
incomplete
4: New Branch
incomplete
5: Switching Branches
incomplete
6: Upleveling Our Abilities
incomplete
7: Log Flags
incomplete
8: Git Files
incomplete
This lesson's interactive features are locked, please to keep using them
You should already be on the main branch: your "default" branch. You can always check with git branch.
git branch my_new_branch
This creates a new branch called my_new_branch. The thing is, I rarely use this command because usually I want to create a branch and switch to it immediately. So I use this command instead:
git switch -c my_new_branch
The switch command allows you to switch branches. Including the -c flag tells Git to create a new branch and switch to it.
When you create a new branch, it uses the current commit you are on as the branch base. For example, if you're on your main branch with 3 commits, A, B, and C, and then you run git switch -c my_new_branch, your new branch will look like this:
Run and submit the CLI tests.
The switch command was introduced in Git version 2.23.0, so you might not have it if you're using an older version of Git.