All the answers I saw here were valid, but there is a much cleaner way to clone a repository and to pull all the branches at once.
When you clone a repository, all the information of the branches is actually downloaded, but the branches are hidden. With the command
git branch -a
you can show all the branches of the repository, and with the command
git checkout -b branchname origin/branchname
you can then “download” them manually one at a time.
However, when you want to clone a repository with a lot of branches, all the ways illustrated in previous answers are lengthy and tedious in respect to a much cleaner and quicker way that I am going to show, though it’s a bit complicated. You need three steps to accomplish this:
1. First step
Create a new empty folder on your machine and clone a mirror copy of the .git folder from the repository:
cd ~/Desktop && mkdir my_repo_folder && cd my_repo_folder git clone --mirror https://github.com/planetoftheweb/responsivebootstrap.git .git
The local repository inside the folder my_repo_folder is still empty, and there is just a hidden .git folder now that you can see with a “ls -alt” command from the terminal.
2. Second step
Switch this repository from an empty (bare) repository to a regular repository by switching the boolean value “bare” of the Git configurations to false:
git config --bool core.bare false
3. Third Step
Grab everything that inside the current folder and create all the branches on the local machine, therefore making this a normal repository.
git reset --hard
So now you can just type the command “git branch” and you can see that all the branches are downloaded.
This is the quick way in which you can clone a Git repository with all the branches at once, but it’s not something you want to do for every single project in this way.