How to clone all branches from a remote git repository
In this tutorial, we are going to learn about how to clone all branches from a remote git repository.
Cloning all remote branches
- First, we need to clone the remote git repository by using the
git clone
command followed by the repository URL or ssh.
git clone <your-repo-url>
- Now, change your current working directory to the cloned repository folder.
cd my-cloned-project-folder
- Next, we need to list all available branches by using the git branch command followed by
-a
flag.
git branch -a
This above command will show you all available remote branches.
- At final we can move to the available branches by using the “git checkout” command.
git checkout <branch-name>
If the branch is available remotely git starts tracking its changes.