I understand that a command to start a new branch is
git checkout -b <mybranch>
However, that assumes I had the foresight to have created the new branch before making the new changes that I want to commit.
Usually however that's not the case. Usually, I start coding, then may or may not do git add . then want to commit in a new branch. How do I do that?
Do it anwyay:
What you'll see is something that looks like this:
You haven't committed anything into Git; with
git add, you've only moved the files into staging. You can still create a new branch with your staged work. Any changes that aren't staged yet will have the opportunity to become staged on the new branch.