gitpractice.dev

brewly — Ch.1 · Write a real commit message

Exercise 9 of 11

Before you start

A good message

The first line is a summary, like a headline: "Add a search box". Aim for 8 to 50 characters, and say something specific ("fix" or "update" says nothing).

Then leave an empty line and write the body: a sentence or more on why the change was needed. The code already shows what changed.

Writing it in the editor

Without -m, git opens an editor and waits. Write your message at the top. Lines starting with # are help text and are ignored.

Press "Save and close" (or Ctrl+Enter) to commit. "Close without saving" cancels the commit.

git commit
open the editor and commit the staged changes
git diff --staged
remind yourself what you are describing
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