Empowering you to understand your world

How To Clone All Remote Branches With Git

You can clone all of the remote branches of a GitHub repository using the ‘clone’ command as shown below. However, to view branches outside of the master branch you need to run some additional commands.

git clone https:/github.com/.../name.git

The clone command above will download all branches in the repository. However, the ‘git branch’ command may only show the master branch. Why? This is because local branches aren’t created for the others. You can still access them offline by typing ‘git branch -a’. You should now see all branches listed. You can switch to one of them using ‘git checkout [branchname]‘.

If you want to create local branches for each of them so you can group them with ‘master’ and see them even without the ‘git branch -a’ command, use ‘checkout -b’ as shown below.

git checkout -b branchname

Further Reading

How To Delete A Local Branch In Git

Subscribe to our newsletter
Get notified when new content is published