gitpractice.dev

brewly — Ch.1 · Commit only what belongs

Exercise 6 of 11

Before you start

Small, focused commits

A commit should contain one change that belongs together. The staging area lets you choose what goes in: only staged changes are committed.

Debugging lines such as console.log are for you, not for the team. Leave them unstaged.

git diff
read all changes that are not staged yet
git add <file>
stage one file only, for example git add src/app.js
git add .
stage everything in the folder. Not what you want when something should stay out
git status
check what is staged before committing
git commit -m "What you did"
save only the staged changes
You can reopen this any time with “Lesson”.

Continue on a desktop

Typing git on a small screen is no fun. Open this page on a laptop or desktop to practise.

Back to the path