Git Amend: Fix a Commit Message Before Anyone Pulls
Third day, and Niki already feels less like a guest. Yesterday's two commits went out clean, timeout and typo, each one honest about what it did.
This morning something less clean catches her eye. The commit message for the timeout fix says fix conection timeout. It has been sitting there an hour already. Nobody has seen it. Probably.
She writes to Teo, ready for a lecture. He sends a screenshot instead, his own history from a previous job. Eleven commits in one day. Nine say update. One says update 2. One says fix stuff (agian).
"clean it before somebody pulls. after they pull, it is tattoo."
The Typo, Fixed Without a New Commit
A new commit on top would leave the typo sitting in history right next to its own apology, which is not the same as fixed. The existing commit needs its message replaced in place: api: fix connection timeout, same content, same commit, nothing else about it touched. Two commits in the history before, two commits after.
Teo's tip
git commit --amend -m "..." replaces the message of the most recent commit. The commit's SHA changes too, since a commit's hash depends on its message as well as its content, but its parent stays the same, so it is still one commit sitting where the old one was, not a new one added after it.
One More Thing, Same Commit
While she is in there, she notices the comment above connTimeout still explains nothing about why the value changed, a one-line note she meant to add yesterday and forgot: Lowered after a recent timeout spike., appended right after the existing sentence, same line. It is not a new idea, it is the tail end of the same fix, so it belongs in the same commit too, not a separate one for a single line.
Teo's tip
git add auth/token.go stages the comment line like anything else, then git commit --amend with no -m reuses the existing commit message unchanged, folding the newly staged change into the same commit instead of asking for a new message.
Teo reads the corrected log, says nothing, and goes back to his screen. A few weeks from now she will learn that this is also a compliment.