Git can rewrite history. That’s actually the point.

Rebase, interactive rebase, and cherry-pick -when and how to use them.