Git create new branch from master
To create a new branch from the master
branch in Git, you can use the following command:
git branch <new-branch-name>
Replace <new-branch-name>
with the name you want to give to your new branch.
For example, if you want to create a new branch called feature/new-login-system
, you would run:
git branch feature/new-login-system
This will create a new branch called feature/new-login-system
that is based on the current master
branch.
If you want to switch to the new branch immediately after creating it, you can use the following command:
git checkout <new-branch-name>
For example:
git checkout feature/new-login-system
This will switch you to the new branch and allow you to start working on it.
Alternatively, you can use the -b
option with the git branch
command to create a new branch and switch to it in one step:
git branch -b feature/new-login-system
This will create the new branch and switch you to it immediately.