Branching helps you keep different versions. Each project starts with a master branch. It’s a common practice to create a new branch whenever you want to introduce a new feature that helps separate it from the main code.
Command: git branch [branch_name]
> git branch feature-1
This command creates a new branch named feature-1
from the branch you are currently at.
To view the branch that you created:
> git branch
This also shows you all of your branches on your local machine.
Command: git checkout [branch_name]
> git checkout feature
This command will switch you from the current branch to the mentioned branch in the checkout command.
You could also create and check that branch out with a single command:
Command: git checkout -b [branch_name]
> git checkout -b feature-1