Menu
CoddyTech

Creating A Branch

Part of the Version Control section of Coddy's Terminal journey. Lesson 29 of 58.

To start a new branch, use git branch followed by the name you want:

git branch feature-login

This creates a new branch pointing at the current commit. It does not switch to it. You stay on the branch you were on, but a new pointer now exists at the same place.

Listing branches confirms the new one was created:

git branch
  feature-login
* main

Branch names are conventionally lowercase and use hyphens between words. Common patterns include feature-x, fix-bug-123, and experiment-y.

challenge icon

Challenge

Beginner

Set up the repository and make one commit on main, then create a new branch called feature-search and list all branches.

Every run starts from a fresh copy of the folder, and the whole script in the editor runs again from the top. Nothing is committed for you: begin with git init -q -b main, set git config user.name and git config user.email, and commit the starting file. Keep those lines in the editor. If you clear them you will see fatal: not a git repository.

The expected output shows both branches in alphabetical order, with main still marked as current.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Version Control

Practice on your own: Terminal playground