Polish before publishing — amend, fixup, autosquash
Real coding is messy. You commit the feature, then notice a typo in a comment, then realize you forgot to update one test, then remember the docstring needs a tweak. Pushing four commits like that is noisy. The professional answer is to clean up the local history before push, so what lands on main reads as one coherent story per concern. Three commands do this work: --amend, --fixup, and --autosquash.
git commit --amend replaces the most recent commit with a new commit that combines the previous changes plus whatever is staged now. The original commit's hash is gone; the new commit takes its place. Use this for the typical "I forgot to add this file" or "the message should say X" cases. The amend opens an editor for the message; --no-edit reuses the existing message untouched.
git commit --fixup <hash> creates a new commit marked as "this should fold into commit <hash> later." It is a regular commit you can push, but it carries metadata saying it's a delayed amend. The companion git rebase -i --autosquash reads those markers and arranges the interactive rebase so each fixup commit is squashed into its target — no manual reorder, no message rewrite. git config --global rebase.autosquash true makes this automatic on every interactive rebase.
The flow that makes this hum: as you work, every "oh and also" change becomes a git commit --fixup against the original commit. You push these freely. Before merging or after review, you run git rebase -i --autosquash main and Git assembles the cleaned-up history. The PR's pre-review noisy commits collapse into the intended logical units. Reviewers see the clean version; main never sees the noise.