How to create a new branch
To create a new branch in Git, you can use the following command:
git branch <branch-name>
Replace <branch-name>
with the name you want to give 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 with the specified name, but it won't switch you to that branch. You can verify that the branch was created by running:
git branch
This will list all the branches in your repository, including the new one you just created.
If you want to switch to the new branch immediately, you can use the -c
option:
git branch -c feature/new-login-system
This will create the new branch and switch you to it.
Alternatively, you can use the git checkout
command with the -b
option to create a new branch and switch to it in one step:
git checkout -b feature/new-login-system
This will create a new branch with the specified name and switch you to it.
Note: If you're working on a remote repository, you'll need to push your local branch to the remote repository before others can see it. You can do this by running:
git push origin <branch-name>
Replace <branch-name>
with the name of the branch you created.