Amend & Fixup
You just committed Add config.json, then spot a typo in the message and reach to fix it in place. Git has no such button: change one byte and git cat-file -p prints a different object with a different name.
- ▸Change one character of a commit message and its name changes completely; git cannot edit a commit in place.
- ▸"Fixing" the last commit writes a second commit and abandons the first; the original never leaves
.git/objects/until garbage collection. - ▸A commit you already pushed is the one to never rewrite; doing so splits your history from everyone else's.
A commit's name is a SHA-1 hash computed from its own bytes: its tree, its parent, the author and committer lines, and the message. Change any one of those, even a single character in Add config.json, and the hash comes out completely different. A different hash is a different object; there is no operation that keeps the same commit and swaps its contents, because the store is addressed by content.
So "fix the last commit" cannot mean edit in place. Whatever git does when you correct that message, it has to produce a *new* object. And because the store is addressed by content, the old bytes do not vanish when you stop using them: the original commit stays inflatable by its old hash. Hold onto both halves of that, a new object appears and the old one survives, because the next two parts are just those two facts playing out on disk.