GitHub & Projects
How to Write Commit Messages That Actually Help Future You
Commit messages are notes from past you to future you. A simple format, small commits, and five habits keep your Git history readable when it matters most.
Scroll through the commit history of almost any student project and you will find the same archaeology: "fix", "update", "final", "final v2", "asdf", and the dreaded "fixed stuff". Nobody writes those messages to be unhelpful. In the moment, the code is the point and the message feels like paperwork. But a month later, when something breaks and you are hunting through that history for the commit that introduced the bug, those messages are a wall. A commit message is not paperwork. It is a note from past you to future you — and future you is the person who will need it most.
Why commit messages matter more than you think
A commit message has three readers, and you are the most important one. The first is future you, debugging at midnight, running git log and trying to remember why a particular change exists. A message that says "Fix crash when search input is empty" answers that question in one line. A message that says "fix" answers nothing, and you will spend the next twenty minutes reading the diff to reconstruct what you already knew when you wrote it.
The second reader is anyone who works with your code — a teammate, a reviewer on your first open-source pull request, a teacher checking your lab. They cannot see your intentions, only your history. A readable history tells them you work deliberately, and it makes their job easier: reviewing a pull request with clear messages takes half the time, because each commit explains itself.
The third reader is the stranger deciding whether to hire you. A maintainer or interviewer who opens your GitHub can see your commit history in seconds, and clean messages are quiet evidence of engineering judgment — the same kind of evidence a portfolio case study is built from. Nobody has ever lost an opportunity because their commit messages were too clear.
The anatomy of a good commit message
A good commit message has two parts, and most commits only need the first. The subject line is one short sentence, ideally under fifty characters, written in the imperative mood — as a command to the codebase. "Add login validation", not "Added login validation". The imperative reads naturally because a commit is a change being applied, and it keeps messages short, because commands have no room for filler.
The body is optional, and you should use it whenever the why is not obvious from the what. One or two sentences explaining the reason, the trade-off, or what to watch for. The rule is simple: the subject says what changed, the body says why it had to change. Code shows what you did; only the message can say why you did it. Here is an example of both parts working together:
Add password validation to login form
The form accepted empty passwords and submitted anyway,
which returned a confusing server error. Validate on the
client first and show a clear message instead.That message would still be useful a year from now, because the reason is written down next to the change. Without the body, a future reader would have to guess whether the validation was a bug fix or a teacher's requirement — and guesses about old code are usually wrong.
A simple format that works every time
You do not need a formal specification to write good messages. A simple pattern covers almost every student commit: an optional short prefix for the kind of change, then a clear subject. Compare the two columns below — the difference is not talent, it is ten seconds of thinking before pressing enter:
Bad Good
--- ----
fix fix: stop crash on empty search input
update Add pagination to complaints list (10 per page)
final v2 Remove unused auth helper after refactor
asdf docs: add setup steps to README
changes style: format login page with project linterCommit small, commit often
Good messages are hard to write for big commits, because a big commit does five things at once and no single sentence describes it. That is a sign the commit is too large, not that the message is too hard. A commit should be one logical change: one fix, one feature, one refactor. If your message needs the word "and" twice, split the commit.
Small commits make everything else easier too. Reverting a bad change means reverting one small commit instead of untangling a day's work, and reviewing means reading one idea at a time. Students often commit once at the end of a long session, when the work is a blur and the message can only be "stuff". Committing as you finish each small piece — the feature works, commit; the test passes, commit — turns the message from a chore into a natural summary of what you just did.
What to do when the message is already bad
Everyone has a history full of "fix" and "update", and it is not a permanent record you have to live with. If the bad message is your most recent commit and you have not pushed yet, you can rewrite it in place:
git commit --amend -m "Add pagination to complaints list"If the bad messages are a few commits back, an interactive rebase lets you rewrite them — again, only before pushing, and only on a branch nobody else is using. The command opens an editor listing your recent commits; change "pick" to "reword" on the ones you want to fix, and Git will ask you for each new message in turn.
git rebase -i HEAD~3 # rewrite the last three messages, before pushingThe rule to never break: do not rewrite history that is already pushed and shared. Rewriting a pushed branch confuses everyone who has pulled it, and no commit message is worth that. If a bad message is already public, leave it — and write the next one properly. A history that improves over time tells its own good story.
Five habits that keep your history readable
- Decide the message before you commit. If you cannot describe the change in one sentence, shrink it until the sentence is obvious.
- One change per commit. A commit that does one thing has one obvious message. A commit that does five things has no honest message at all.
- Imperative mood, present tense. "Add", "Fix", "Remove" — commands, not diary entries. It keeps messages short and consistent.
- Say why when the why is not obvious. A change that looks strange now will look incomprehensible in three months. One sentence of reason is enough.
- Read your own log once a week. Run git log --oneline and read it like a story. If it reads like a story — each line a clear step — you are doing it right. If it reads like a list of grunts, you know what to fix.
Your commit history is the only documentation that is guaranteed to be read — by you, at 1 AM, when something is broken.
Start with the next commit
You do not need to fix your whole history to start benefiting from this. You only need the next commit to have a real message — one sentence, imperative, naming what changed and why. Then the one after that. Within a week, your log reads like a record of decisions instead of a pile of saves, and the first time you track down a bug by reading your own messages instead of re-reading your own code, you will understand why it was worth the ten seconds. If this is the year you start contributing to other people's projects, the habit matters even more — read How to Make Your First Open-Source Contribution as a Student and notice how much easier a maintainer's job is when every commit explains itself.