Git new branch command
The git branch
command is used to create, list, rename, and delete branches in a Git repository.
To create a new branch, you can use the following command:
git branch <branch-name>
Replace <branch-name>
with the name you want to give to 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 the git checkout
command:
git checkout feature/new-login-system
Alternatively, you can create a new branch and switch to it in one step using the -b
option:
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 an existing branch (e.g., the current branch), you can use the -b
option with the name of the existing branch:
git checkout -b feature/new-login-system origin/master
This will create a new branch called "feature/new-login-system" based on the "master" branch.