This variation will clone a remote repo with all branches available locally without having to checkout each branch one by one. No fancy scripts needed.
Make a folder with the same name of the repo you wish to clone and cd into for example:
mkdir somerepo
cd somerepo
Now do these commands but with actual repo usersname/reponame
git clone --bare [email protected]:someuser/somerepo.git .git
git config --bool core.bare false
git reset --hard
git branch
Voiala! you have all the branches there!