Most mistakes in Git can be undone. Prefer commands that add new history over ones that rewrite it, especially on shared branches.
git restore file.txt # throw away uncommitted changes in a file git restore --staged file.txt # unstage, keep the changes git commit --amend # fix the last commit (before pushing) git revert abc1234 # undo a pushed commit with a new commit git stash && git stash pop # park work temporarily