How to create a branch from master in Git
In this tutorial, we are going to learn about how to create a branch from master in git.
Creating a branch from master
- First, you need to move to a master branch using the
git checkout
command followed by themaster
.
git checkout master
Note: if you are already in the master branch you don’t need to run the above command.
- Create a new branch based on the master by using the below command.
git branch my-new-branch
- Now, Switch to the new branch using the
git checkout
command.
git checkout my-new-branch