Checkout to a new branch
To create a new branch and switch to it, you can use the following Git commands:
-
Create a new branch:
git branch <branch-name>
Replace
<branch-name>
with the name you want to give your new branch. -
Switch to the new branch:
git checkout <branch-name>
This will switch your local repository to the new branch.
Example:
git branch feature/new-login-system
git checkout feature/new-login-system
This will create a new branch called feature/new-login-system
and switch your local repository to that branch.
Note: If you want to create a new branch and immediately switch to it, you can use the -b
option with the checkout
command:
git checkout -b <branch-name>
This will create a new branch and switch to it in one step.