Menu
Coddy logo textTech

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 icon

Challenge

Easy

Create 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

Terminal
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
quiz iconTest yourself

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

All lessons in Version Control