What Do I Write in a Commit Message? (Beginner Guide)
Every time you save your work with git, it asks you for a message. Most beginners just type something quick: fix, asdf, or final. Six months later, that message is useless, and you have no idea what you actually changed.
A good commit message says what changed and why, written for future you, so your git history becomes a clear record you can actually read instead of a wall of “fix” and “final”.
What is a commit message, really?
A commit message is the short note you attach to each saved checkpoint in git. It travels with that change forever, so anyone looking back at the project, including you, can understand what happened without opening the code.
Think of it like a note-to-self. A note that just says “things” is useless. A note that says “call Riya about rent” still makes sense weeks later. Your commit message is exactly that kind of note.
Why does a clear commit message matter?
Picture your own project history a few months from now. If every line just says fix or final, none of them tell you anything. You are forced to read the actual code to remember what you did.
A clear message changes that. Here is what it gives you:
- Old work becomes easy to find. You can scroll your timeline and spot the right change in seconds.
- Mistakes become easy to undo. When something breaks, a good message points you straight to the commit that caused it.
- Teammates instantly understand. They read the message, not your mind.
A few seconds of writing now saves you hours of confusion later.
What should I actually write?
The rule is simple: say the what and the why. You do not need fancy words. You need to be clear and specific.
Here is a clear example:
fix login button on mobile
That tiny line does a lot of work. fix login is the what changed. on mobile is the where, which hints at the why. Together they make the change obvious, and anyone can read it and understand.
Compare that to a bad message that is just stuff or asdf. Same amount of typing, but one helps future you and the other does not.
How do I write one in the terminal?
You can try this right now. Open a terminal in a project where you have already used git add, then run:
git commit -m "fix login button on mobile"
The -m flag (short for “message”) lets you write the message right there in quotes. Git saves that message permanently alongside the change.
A handy habit: write your message as if it finishes the sentence “This commit will…”. So “add signup form” or “fix login button on mobile” both read naturally. If yours does not fit that pattern, it is probably too vague.
Key takeaways
- A commit message is a note attached to each saved change in git, kept forever.
- Write it for future you: say what changed and why.
- Good:
fix login button on mobile. Bad:fix,asdf,final. - Use
git commit -m "your clear message"to save it. - Clear messages make old work easy to find, mistakes easy to undo, and teammates instantly informed.
This lesson builds on understanding how real teams use git daily in the free Zero to AI Hero course. Once your messages are clear, the next step is putting it all together in a full git cycle, from change to commit to share, which is exactly where we head next.
🚀 Take the full free course: Zero to AI Hero — learn to build with AI from scratch. New lessons daily, in Hindi & English.
Want to actually learn this?
151 free 2-minute lessons — from "what's a file?" to building with AI.
▶ Start the free course