Here is the easy way to clone a specific git branch in a local machine.
- First clone repository.
git clone <repository_url>
- List all branches.
git branch -a
- Checkout the branch that you want to clone.
git checkout <name_of_branch>
- After that apply the following commands to execute pulls and pushes without having to specify the target branch.
git branch --set-upstream-to=origin/<branch> <local_branch>
Keywords: clone specific branch.