How to Clone Remote Git Branches

The idea of cloning is to download the complete source code to the local machine. Since it is a very important process in Git, we will show how you can clone branches from the remote repository.

Steps to cloning remote branches

Here we suggest 4 steps that you can take and have a copy of a remote git branch:

Cloning the remote and change direction

Firstly, clone the remote repository and cd into it.

git clone git://
cd exampleProject

Listing branches

Secondly, use the git branch command for listing the branches and git branch with the -a option for listing all remote branches:

git branch // Lists local branches
git branch -a // Lists local and all remote branches

Checking out the remote locally

Then, check out the remote branch locally. If the name of the remote branch and the one of the checked out branch turns out the same, it will automatically track the remote branch:

git checkout <branch>

Fetching the remote

Now let’s fetch the remote master branch:

git clone
cd example
git checkout master

Concept of Cloning

When cloning a repository, all the files are downloaded to the local system not affecting the remote git repository. The git clone command clones and copies of an existing repository into a new directory. It is also used to create remote-tracking branches for each branch in the cloned repository. It also allows users to get a development copy of an existing central repository.

Remote Branches

The git branch command creates, lists and deletes branches. It not only operates on the local branches but also remote branches. Remote branches are pointers to the state of branches in the remote repositories. These branches are local and they cannot move unless you operate. Remote branches are reminders of where the branches on the remote repositories were the last time you worked on them.