Branch conventions and commit messages
Understand the idea
Short branch names and commit messages that say why save the next reader a search.
The idea
The graph already shows what changed. Names tell a teammate where to look and why the exists. Use a short name for the intent, such as fix-empty-login. Write a message that would still make sense next to the diff in a .
What changes
The commands are the ones you already know: git switch -c fix-empty-login and git commit -m "Reject empty login instead of submitting it". What changes is the reader's job. git log --oneline becomes a list of reasons. The branch list becomes a list of tasks. Conventions do not move HEAD. They make the labels worth reading.
| Weak | Clear | Why |
|---|---|---|
| wip | fix-empty-login | The branch says the task |
| update | Reject empty login instead of submitting it | The message says why |
| asdf | docs: describe the three states | A prefix can name the kind of change |
The command
Create a branch whose name is the task. Commit with a message a reviewer could repeat without opening the file. Then git log --oneline --graph. If the line only makes sense to you today, rewrite it with git commit --amend before anyone else has fetched it.
The mistake
Check your graph
The branch chip should read like a task, and the commit message should say why. A teammate who only reads the graph should know which node to open.
Your repository
Name a branch and a commit so a teammate can tell the intent without opening the diff.
Step 1
Name the branch for the task
fix-empty-login says what the work is. If you already created it, run git switch fix-empty-login.
Step 2
Make the change
In the editor, set login.txt to: Reject an empty login instead of submitting it
Step 3
Stage it
The diff is the what. The next message is the why.
Step 4
Write the reason
A teammate should understand this line without opening the file.
Step 5
Read the graph as a teammate
The branch name is the task. The commit message is the reason.
The editor edits the working tree. Start a repository and the files appear here.
Commit graph
No commits yet. git init creates the first one.
Quiz
A quick check for understanding. Retry as often as you like; your learning path stays open.
Ready to call this one understood?
Mark this lesson complete to earn 200 XP. You can always revisit it.