WeCodeAcademy

Creating and Switching Branches

A branch is a separate line of work. You can try an idea on a branch without touching main.

Examplebash
Open in editor »
/ $

The * marks the branch you are on. Notice that feature.txt disappears when you go back to main, and comes back when you return to feature. git switch <name> does the same as git checkout <name>.

Quick check

Which command creates a new branch and switches to it?

Your turn: write the code

Make a first commit, create a branch called feature and switch to it, then print the branch list with git branch.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.