Git tracks changes. A commit is the unit it tracks them in.
The flow looks like this:
- You edit some files in the repository.
- 2. You pick which of those changes belong together (Git calls this staging).
- 3. You commit them with a message.
Git now has a permanent record: which files changed, which lines, who did it, when, and the message.
The message is the part beginners skip. "update" and "fix stuff" tell you nothing a month later. "Return 404 when the user id doesn't exist" tells you exactly what happened, and it even ties back to the status codes from Day 10.
A useful rule: if you can't describe the change in one line, it's probably two commits.
Quick check: You fixed a typo on the home page and also rewrote the signup form. One commit or two?
## SPOKEN LINES
- You broke the login button somewhere in the last three hours. In a Google Doc you would open version history and step back.
- - COMMIT
- - A commit is a saved snapshot of your code changes. You change a few files, write a short note about what you did, and Git stores the snapshot with your name and the time.
- - One commit says fix login button on mobile, the next says add dark mode toggle, and the one from last Tuesday says remove old checkout page.
- - So a commit is a save point for your code with a note attached. Tomorrow: Branch, a separate line of work that keeps main safe.
## NEXT
Day 22: Branch