Create new git branch and checkout
Here are the steps to create a new Git branch and checkout:
Create a new branch:
git branch <branch-name>
Replace <branch-name>
with the name you want to give your new branch. For example:
git branch feature/new-login-system
This will create a new branch named feature/new-login-system
that is based on the current branch (usually master
).
Checkout the new branch:
git checkout <branch-name>
Replace <branch-name>
with the name of the branch you just created. For example:
git checkout feature/new-login-system
This will switch your Git repository to the new branch. You can verify this by running:
git branch
This will show you a list of all branches, including the current branch, which should now be feature/new-login-system
.
Note: If you want to create a new branch and immediately switch to it, you can use the following command:
git checkout -b <branch-name>
This will create a new branch and checkout to it in one step. For example:
git checkout -b feature/new-login-system
This will create a new branch named feature/new-login-system
and switch to it.