← Lessons/Branching & Merging
← Branching & Merging

Commit on the branch

Learn

Commit on the branch

Commits go onto whichever branch you're on. Create a file, stage it, commit it, and the new commit belongs to your branch alone; main hasn't moved.

echo "hello" > notes.txt
git add notes.txt
git commit -q -m "Add notes"
git log --oneline

git log shows the branch's history: your new commit on top of the commit it started from. The terminal continues from the previous mini lesson, so you're already on your branch.

On the feature branch, create a feature.txt file, stage and commit it with the message Add feature, then git log --oneline to see both commits.

sandbox@opspath: ~
OpsPath sandbox · Debian GNU/Linux 12 · GNU bash 5.2
Your session carries over: files, commits, branches and cd all stick.
Press restart (top right) to go back to this mini lesson's starting point.
Type a command and press Enter. ↑/↓ history · Ctrl+L clear · Ctrl+C cancel line
# ── Step 2 · Commit on the branch ──
# Sign in to run commands — it's free.