Create a new branch and switch
Here are the commands to create a new branch and switch to it:
Create a new branch:
git branch <new-branch-name>
Replace <new-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 called feature/new-login-system
that is based on the current branch (usually master
).
Switch to the new branch:
git checkout <new-branch-name>
Replace <new-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
again, which should show you that you are now on the feature/new-login-system
branch.
Note: If you want to create and switch to a new branch in one command, you can use:
git checkout -b <new-branch-name>
This will create a new branch and switch to it in one step. For example:
git checkout -b feature/new-login-system