reset, restore, revert — how to get out of a mess
git reset --hard HEAD~1nukes the last commit and all its changes. gone. use with caution.
git reset --soft HEAD~1removes the last commit but keeps the changes staged. useful if you committed too early and want to rework things.
git restore src/some-file.tsdiscards unstaged changes to a file. brings it back to what it was at HEAD. can't undo this so be sure.
git restore --staged src/some-file.tsunstages a file without throwing away your changes. it's just removed from the upcoming commit.
git revert abc1234creates a new commit that undoes a previous one. this is the safe option if the commit has already been pushed to a shared branch — it doesn't rewrite history.