In this lesson
Everything will break at some point. The difference between panic and routine is knowing how to read the error and having somewhere to go back to.
An experienced programmer does not make fewer mistakes. They have a method: they read the error calmly and keep every version that worked.
- Turn an error message into a request the AI can solve
- Understand git and use four commands
- Go back to a version that worked
Where the error shows up
- In the terminal, when the server does not start. The last lines hold the cause.
- In the browser console, when a button does nothing. Press F12 and open the "Console" tab. The error comes in red.
- On the screen, if the app shows clear errors.
You do not need to understand the message. You need to copy all of it.
The fix request
There are four ingredients: the symptom, the message pasted in, what you did and what you expected. Plus the limit "only this problem".
Tip
If the AI says "fixed" and the error is still there, do not repeat the request. Paste the current message and say the error is the same. On the third failed attempt, go back to a saved version.
Real example
The owner of a clothing store had a tool to keep track of exchanges. The "record" button stopped working after a layout adjustment. She opened the console, saw the error in red, pasted it into the conversation with the four ingredients, and in one minute it was solved. Before, she thought she "had broken everything".
Git, without the mystery
Git keeps the history of the project. Every time you "save a version" (a commit), it takes a snapshot of all the files, with a message from you. Everything stays on your computer, in a hidden folder called .git.
| Command | What it does |
|---|---|
git init | Starts the history (once) |
git add . | Marks the changed files for the next snapshot |
git commit -m "message" | Takes the snapshot and stores it |
git log --oneline | Lists the snapshots, one per line |
The message is for you three months from now. "Tweaks" says nothing. "Fixes the export button that was not downloading the file" says it all. Make a commit for every small change that worked.
Careful
Create the .gitignore with .env in it BEFORE the first git add .. If the API key goes into a commit, the only safe way out is to revoke it and create another one. Deleting the file afterwards does not remove the key from the history.
What the pros know
Git almost never truly loses a commit. There is a record of your project's latest positions, the git reflog. By default, it keeps the entries for 90 days, and those of commits that were left "dangling" (for example, after a reset or after amending the last commit) for 30 days. If you went back and wiped out a good version by accident, run git reflog, find the commit in the list and go back to it. Just do not count on it after that period.
Going back
The scenario: you asked for a fix, the AI touched five places and now two buttons have stopped working. If you made one commit per fix, going back one version loses only that fix. If you made one commit per day, you lose the whole day. That is why the pace matters: small, frequent commits. To go back, ask the AI: "the last change broke the menu; take the project back to the last commit".
Practice · 10 min
- Ask the AI for a
.gitignorefor the project. Then rungit init,git add .andgit commit -m "first version". - Cause an error on purpose (for example, delete a line from the file). Copy the message and ask for the fix with the four ingredients.
- When it works, make a commit with a clear message and run
git log --oneline.
Summary
- Copy the whole error message and use the four ingredients.
- Git keeps versions on your computer: init, add, commit and log.
- Create the .gitignore before the first commit.
- Small, frequent commits let you go back with little loss.
Sources
Read on October 30, 2026.
- Git. git-gc: gc.reflogExpire (90 days) and gc.reflogExpireUnreachable (30 days).
Lesson quiz
Three situations to apply what you learned.
Isaque Victor free courses