Chapter 1 of 7 · 4 practices · 3 min · 3-question quiz
Commits and commit messages
How big a commit should be and how to write a message that still makes sense a year from now.
Start: Make each commit one logical change4 practices in this chapter
- 1Make each commit one logical changeA commit is the unit you review, revert and search through later, so its size decides how useful your history is. Mixing a bug fix, a formatting pass and a new feature in one commit makes it hard to…
- 2Write a short summary line, a blank line, then explain whyA commit message is read far more often than it is written: in
git log --oneline, in patches, in blame views and in many tools. The Git documentation recommends a simple shape. - 3Review and stage changes in pieces with git add -p
git add .stages everything, including debug prints, temporary files and unrelated edits. Staging in pieces keeps commits focused and doubles as a quick self review: you read every line before it… - 4Set your identity and a few helpful defaults onceA few settings, made once with
git config --global, make every commit attributed correctly and remove small daily annoyances.
Check yourself on this chapter
3 questions, right here once you are signed in. Your progress is saved as you read.