I recently ran into an issue where I needed to clone a specific branch for a project that I was working on. Here’s how to do that:
git clone -b nameOfBranch https://address-of-git-repo.com/yourusername/repo.git
Using -b
will fetch all the branches, but it will checkout the branch that you typed in after -b
. You can double check that you are in the branch that you cloned by typing git branch
.