Create new branch from remote branch git
To create a new branch from a remote branch in Git, you can use the following command:
git checkout -b <new-branch-name> origin/<remote-branch-name>
Replace <new-branch-name>
with the name you want to give to your new branch, and <remote-branch-name>
with the name of the remote 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 remote branch master
, you would use the following command:
git checkout -b feature/new-login-system origin/master
This will create a new local branch called feature/new-login-system
that is tracking the remote branch master
.
Alternatively, you can use the following command to create a new branch from a remote branch and then switch to it:
git branch <new-branch-name> origin/<remote-branch-name>
git checkout <new-branch-name>
For example:
git branch feature/new-login-system origin/master
git checkout feature/new-login-system
This will create the new branch and then switch to it.
Note: Make sure you are in the correct repository directory and that you have already cloned the remote repository before creating a new branch.