0/3

Lesson04

beginner

Switch Between Branches

Goal

Move between branches with git switch, and create-and-switch in one step with -c.

A feature/login branch already exists. Move HEAD onto it, come back to main, then create a brand-new branch and switch to it in a single command.

Watch the blue HEAD label in the graph move as you switch.

Objectives

0/3
  1. Switch to the feature/login branch. (Current objective)
  2. Switch back to main. (Not started)
  3. Create a branch named bugfix/header and switch to it with a single command. (Not started)

Your task nowStep 1 of 3

Switch to the feature/login branch.

Need help?

Reference

Switch to an existing branch

$ git switch feature/login

Switched to branch 'feature/login'

Create a branch and switch to it

$ git switch -c bugfix/header

Switched to a new branch 'bugfix/header'

-c stands for "create". It does the same as git branch bugfix/header followed by git switch bugfix/header.

Preparing your workspace…

Repository Graph

Click a commit to inspect it

0 commits

Working Tree

Not a Git repository yet

No unstaged changes

Your working tree matches the staging area.

Staging Area

Files prepared for the next commit

No staged changes

Use git add to prepare files for your next commit.

Repository

Committed history

No commits yet

Use git commit to record staged changes.