World map

 

BM: Baca dalam Bahasa Melayu

World 11: Rescue Center

Fix a bad commit message

You will learn: how to fix a commit message, and when to leave it alone.

The problem

git log --oneline: the newest commit says only: stuff. Terminal output: $ git log --oneline 54f2d43 (HEAD -> main) stuff 270a76e Add style a8feb63 Add day 1 page 6d3a9b1 Add README

Your last commit says stuff. Stuff? Next week, nobody will know what it was. Not even you! This happens to everyone.

Try it

You haven’t pushed yet. What’s the quickest fix?

Pick one answer.

Watch

The stuff commit is swapped for a new commit, Add day 2 entry. main now points at the new one.
6d3a9b1a8feb63270a76e54f2d43

amend: Replace your last commit with a fixed one. swaps your last commit for a fresh copy. Same changes, new message, new hash.

Try it

Give the last commit a clear message.

6d3a9b1a8feb63270a76e54f2d43

Predict

New story: it’s pushed, and teammates pulled it. Now what?

Pick one answer.

Check

Clear message, or needs work? Swipe each one.

Swipe right for good, left for needs work. Or use the buttons.

1 / 4Add day 2 entry
Add day 2 entry

You did it!

You can now fix a bad commit message, safely.

Go deeper (optional)

Bad message on an older commit? Before you push, git rebase -i can reword it (World 3). Already pushed, but on a branch only you use? Amend, then git push --force-with-lease replaces it safely (World 4). Never do that on a shared branch like main.