In short
A commit is a save point you can always come back to. Good commits mean you can break your API at 2 a.m. and still roll back calmly.
`git commit` saves a snapshot of your staged changes with a message — the fundamental unit of history in Git.

Think of it like this
The family photo album
At every function, someone clicks a photo and pastes it in the album with the date. Years later you can flip back to any moment. Each commit is one photo of your project, with a note saying what changed.
Watch it happen
From edit to commit
1/4You edit routes/users.js. Git notices the file changed but saves nothing yet.
The big ideas
What you need to know
Staging lets you choose
You can change five files but stage only two. The commit then contains only those two, keeping each save focused.
Every commit has a hash
A long ID made from the content. Change one character and the hash changes, so history can't be quietly edited.
Write the why
"Fix login 500 when email is empty" beats "update". Future you will search these messages.
Small and complete
One commit, one idea. The code should still run after each commit so rollbacks are safe.
See it in code
Walk through the code
1git status # what changed?2git diff # exact lines changed3 4git add src/routes/users.js5git commit -m "Add GET /users endpoint"6 7git add -p # pick changes hunk by hunk8git commit -m "Validate email on signup"9 10git log --oneline # a1b2c3d Validate email on signup1/4Always look before you save. diff shows the exact lines you changed.
git add -p shows each changed chunk and asks y or n. It's the easiest way to split messy work into clean commits.
Save yourself the pain
Common mistakes
Oops
One giant commit at the end of the day called "changes".
Do this instead
Commit each small working step with a message that says what and why. Reviews and rollbacks get much easier.
Oops
Running git add . without checking, and committing debug logs or .env.
Do this instead
Run git status and git diff --staged before every commit. Know exactly what you are saving.
Your mission
Three clean commits
Quick check
You edited app.js and db.js but ran only git add app.js before committing. What's in the commit?
Go deeper
- 1Practice small, focused commits rather than one giant commit per day.
- 2Write commit messages in the imperative mood ('Add', not 'Added').
- 3Learn `git commit --amend` to fix your most recent commit message.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.