Suppose you’ve forked a repo and have cloned a local copy. You’re ready to start making changes, but wait! first you’ll want to create a new branch first before making your modifications. (Don’t worry if you forget this step. I always do. Fortunately, you’re using Git now and there’s a way to do anything and everything it seems. I’ll cover how to get out of this state gracefully in a future tip.)
You could use two separate commands
> git branch <branch-name>
> git checkout <branch-name>
or use a shortcut that automatically creates a branch and switches to it using the –b switch:
> git checkout –b <branch-name>
as shown in the image below
Suppose you’ve made a typo and misspelled windows as widnows.
You can fix this by renaming the current local branch using the following command:
> git branch –m windows
As seen in the image below.
Now you might be wondering why a –m switch and not a –rn switch. This is because –m stands for move, and since Git started on UNIX-based systems, Git uses a lot of the UNIX nomenclature. So to rename a file in a UNIX system, you need to move the file to its new name. Thanks to this SO answer.