Today I learned about the --force parameter of git branch which will take an existing branch and point it to a different commit. This is another handy alternative to git reset --hard for some common scenarios.
For example, if I forgot to create a new feature branch and accidentally made some commits onto main, I can run the following:
git checkout -b new-branch # create the new branch and switch to it git branch --force main origin/main # fix main back to what it should be vs what I would do before:
...