Your first commit
The three-step rhythm — change, stage, commit — that every save point follows.
Now the hands-on part. Making a commit is a rhythm of three steps. Once it’s in your fingers, you’ll do it without thinking.
The three steps
- Change — you edit files. Git notices, but does nothing yet.
- Stage — you tell git which changes belong in the next snapshot (
git add). - Commit — you take the snapshot and label it (
git commit).
Why two steps to save (stage then commit)? Because sometimes you change five things but only want to snapshot two of them together. Staging lets you choose. For now, it’s fine to just stage everything.
$git add .
The . means “everything I’ve changed.” This stages your changes — puts them on deck for
the next commit.
$git commit -m "Add contact form to homepage" [main a1b2c3d] Add contact form to homepage 1 file changed, 24 insertions(+)
That’s a save point. The -m is the message — a short note to your future self about
what this snapshot contains.
Writing a good commit message
The message is you leaving a trail. Six months from now, scrolling through history, “fixed stuff” tells you nothing. “Fix login button not working on mobile” tells you everything.
Which of these is the most useful commit message?
Seeing your history
Once you have a few commits, git log shows them, newest first:
$git log --oneline a1b2c3d Add contact form to homepage 9f8e7d6 Fix broken logo image 3c2b1a0 Initial commit
Each line is a save point: a short hash (the ID, like a1b2c3d) and your message. That
top hash is where you are right now.
You've been coding for 20 minutes and the feature now works. What's the right instinct?
Try it for real
Time to actually do it. In any project you have locally (or a throwaway folder):
- Create a file — even just a
notes.txtwith one line in it. - Run
git status. See your file listed as untracked or modified. - Run
git add .thengit statusagain — notice how the file moved to “staged.” - Run
git commit -m "My first real commit". - Run
git log --onelineand admire your save point.
If the folder isn’t a git project yet, run git init first to create the .git time
machine. That’s it — you’ve made a commit.