Work On A Branch
Part of the Version Control section of Coddy's Terminal journey — lesson 52 of 58.
The new feature is "add a task to the list". You will do that work on a branch, not on main.
Create and switch to the branch add-task, append a new line to todo.txt, and commit it. The change should exist only on the branch.
Challenge
EasyCreate and switch to a branch named add-task. Append the line walk the dog to todo.txt. Stage and commit with the message Add walk task.
Then print the contents of todo.txt.
Cheat sheet
Create and switch to a new branch, make changes, then commit:
git checkout -b add-task
echo "walk the dog" >> todo.txt
git add todo.txt
git commit -m "Add walk task"The -b flag creates the branch and switches to it in one step. Changes committed on a branch do not affect main.
Try it yourself
git init -q -b main
git config user.name "Todo Dev"
git config user.email "todo@coddy.tech"
git add .
git commit -q -m "Seed todo list"
git log -1 --pretty=%s
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Version Control
2Getting 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