git clone remote branch to local code example

Example 1: how do i clone a specific branch in git

git clone -b <your_branchname> <your_git-remote-repo>

Example 2: gitlab clone branch

git clone --single-branch --branch <branchname> <remote-repo>

Example 3: pull and clone origin branch locally

git clone --branch <branchname> <remote-repo-url>
git clone -b <branchname> <remote-repo-url> // -b === --branch

Example 4: duplicate clone remote branch locally git

git checkout -b <new_local_branch_name> <remote>/<remote_branch_name>
// example
git checkout -b my_branch origin/my_branch