Writing good commit messages
Future you will thank you
⏱ Est. ~8 min
01 · Read
A good commit message is a gift to future you (and your teammates). It should explain why you changed something, not just what. Clear messages make git history actually useful.
💡 Picture thisWriting good commit messages is like labeling the back of a photo. "3rd birthday party at Grandma's house" is helpful. "photo" is not. Months later, these labels are the only way you'll remember what each snapshot was.
Key points
- Good messages explain why: 'Fix login timeout for slow connections'
- Bad messages are vague: 'fixed stuff', 'update', 'asdf'
- Keep the first line short (under 50 characters), in the imperative: 'Add', 'Fix', 'Update'
02 · Terminal exercise
You have a blog project with HTML and CSS. Let's practice writing good commit messages with the full workflow.
(This section is interactive — please enable JavaScript.)
03 · Terminal exercise
Stage all the files for your first commit.
(This section is interactive — please enable JavaScript.)
04 · Terminal exercise
Your first commit should describe what's set up in this project. Don't just write 'first commit' — be specific about what your starting point is.
(This section is interactive — please enable JavaScript.)
05 · Quiz
Which of these commit messages follows best practices?
- "fixed stuff"
- "Add user login validation for email format"
- "update"
- "changes"
06 · Terminal exercise
Now let's add a new feature to your blog — a navigation bar.
(This section is interactive — please enable JavaScript.)
07 · Terminal exercise
Stage the modified file.
(This section is interactive — please enable JavaScript.)
08 · Terminal exercise
Write a commit message for this change. Describe what you added — don't just write 'update'. Good examples: 'Add navigation bar to blog', 'Add nav links for Home, About, Contact'.
(This section is interactive — please enable JavaScript.)
09 · Quiz
Which commit message best matches professional conventions?
- "updated stuff"
- "asdfjkl"
- "Fix password reset for expired tokens"
- "I changed the login page to fix a bug where users couldn't log in when their session expired after 24 hours"
Other lessons in this chapter
⚠ The full interactive experience needs JavaScript. Please enable it and reload.
※ This is an independent Traditional Chinese teaching project — not an official Anthropic product. Claude™ is a trademark of Anthropic, PBC.