git clone a specific branch
Quick Answer
git clone -b feature/login https://github.com/user/repo.git
When to use this
You only need one branch of a large repository, or you want to clone a non-default branch directly.
Other causes & fixes
Clone with only the latest commit (shallow + single branch)
Fastest option for CI/CD — downloads only the tip of one branch.
git clone --depth 1 -b feature/login https://github.com/user/repo.git
Switch to a different branch after cloning
git fetch origin other-branch
git checkout other-branch
Clone a specific tag
git clone -b v2.1.0 https://github.com/user/repo.git
Related