Mid Version Control

How do you create and switch to a new branch?

You can create and switch to a new branch using:

git checkout -b feature/login-page

This creates a branch named feature/login-page and switches you to it immediately.

Alternatively, you can do it in two steps:

git branch feature/login-page

git checkout feature/login-page

Real-world example:

If your team assigns you to build a login page, you can create a branch

feature/login-page to isolate your changes from the main code.

More from Developer Essentials

All questions for this course