gitpractice.dev

brewly — Ch.1 · Your first commit

Exercise 5 of 11

Before you start

Stage, then commit

Saving a change takes two steps. First you stage it: you put it in the staging area. Then you commit: git saves everything staged as one snapshot.

Every commit needs a message saying what you did. Put it in quotes after -m.

git status
which files changed, and what is staged?
git add <file>
stage the changes of one file
git diff --staged
review exactly what the commit will contain
git commit -m "What you did"
save 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