If you’re using the terminal, you will use the git branch command followed by your desired branch name to create a Git branch in your repository.
It should look something like this:
git branch feature-A
This will create a Git branch on your currently checked-out reference.
If you’re not using the power of the best visual tool for Git, GitKraken, which displays the branches in your Git repository, you can run the git branch command to view a list of your local branches and confirm that your newly created branch appears.
After you have created a Git branch, you can use the git checkout command followed by the branch name to checkout that branch.
git checkout feature-A
Once you’re comfortable with how to create a Git branch, you will likely enjoy the ability to create a new branch and checkout the branch using one command.
You can combine the two actions of creating and checking out a branch in Git with:
git checkout -b <branch name>
This will create a new branch and immediately checkout the branch.
By comparison, if you’re using the GitKraken Git client to help visualize your repository, creating a branch is even easier.
Simply right-click on any branch or commit and select Create branch here.
ProTip: GitKraken will automatically checkout the branch for you immediately after the branch has been created, so you can get straight to work on the right file.
Alternatively, you can use Cmd/Ctrl + P to launch the GitKraken Fuzzy Finder and type Create Branch. This will jump you straight into the create branch field for whichever reference you currently have checked out.
Make branch management in Git more intuitive, and save time creating branches in Git, with the legendary cross-platform GitKraken Git client for Windows, Mac, & Linux.