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-loginThis 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
* mainBranch names are conventionally lowercase and use hyphens between words. Common patterns include feature-x, fix-bug-123, and experiment-y.
Challenge
BeginnerThe repo already has one commit on main. Create a new branch called feature-search. Then list all branches.
The expected output shows both branches in alphabetical order, with main still marked as current.
Cheat sheet
Create a new branch (without switching to it):
git branch feature-loginList all branches (* marks the current one):
git branch
feature-login
* mainBranch naming convention: lowercase with hyphens, e.g. feature-x, fix-bug-123.
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Version Control
7Branching
What Is A BranchCreating A BranchSwitching BranchesCommitting On A BranchDeleting A BranchRecap - Branch Play2Getting Started
Initialize A RepositoryThe .git FolderConfigure Your IdentityGit StatusRecap - First Repo8Merging
What Is A MergeFast-Forward MergeThree-Way MergeMerge ConflictsResolve A ConflictRecap - Merge Master11Feature Branch Project
Project OverviewInitialize Main3Tracking Changes
The Staging AreaGit AddGit CommitModifying A Tracked FileGit LogRecap - First Commits6Recipe Site Project
Project OverviewInitialize And Ignore