Create new branch from exisiting brancg
To create a new branch from an existing branch in Git, you can use the following command:
git branch <new-branch-name> <existing-branch-name>
Replace <new-branch-name>
with the name you want to give to the new branch, and <existing-branch-name>
with the name of the existing branch you want to create the new branch from.
For example, if you want to create a new branch called "feature/new-login-system" from the existing branch "master", you would use the following command:
git branch feature/new-login-system master
This will create a new branch called "feature/new-login-system" that is based on the current state of the "master" branch.
You can also use the -b
option to create a new branch and switch to it immediately:
git checkout -b <new-branch-name> <existing-branch-name>
This will create the new branch and switch to it, so you can start working on it right away.
For example:
git checkout -b feature/new-login-system master
This will create the new branch "feature/new-login-system" and switch to it, so you can start working on it.
Note: If you want to create a new branch from the current branch (i.e., the branch you are currently on), you can simply use git branch <new-branch-name>
without specifying the existing branch name.