This tutorial will help you to clone a specific branch from the remote Git repository.

Clone Specific Git Repository

You can clone any remote repository with git clone command. The default clones the master (main) branch from remote. You can also specify the branch name with -b option to clone a specific branch. The above command clones the specific branch but fetches the metadata of other branches. You can view all branches details with command git branch -a. To skip metadata of other branches use –single-branch option like: That’s it. Switch to the newly created directory and type git branch to check the branch.


In this write-up, you have learned to clone a specific Git branch from a remote repository like Github, Gitlab, Bitbucket, or a self-hosted Git server.