Git create 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, 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. To switch to the new branch, you can use:
git checkout feature/new-login-system
Alternatively, you can create a new branch and switch to it in one step using:
git checkout -b feature/new-login-system
This will create a new branch called "feature/new-login-system" and switch you to that branch.
Note: If you want to create a new branch based on the current branch, you can use:
git branch feature/new-login-system
This will create a new branch with the same commit history as the current branch.
Also, you can use git branch
command with -a
option to list all branches, including remote branches:
git branch -a
This will show you a list of all branches, including the current branch, and you can use the checkout
command to switch to any of them.