Skip to main content

Explore your training options in 10 minutes

Git: Pull All Branches

James Gallagher - September 24, 2020

Git lets you maintain multiple separate lines of development for a project. These lines of development are called branches. You can retrieve the latest version of a branch from a remote repository independently or you can retrieve the latest version of all branches at once.

In this guide, we talk about how to use the git fetch –all and git pull –all command to retrieve changes from a remote repository.

What is Branching?

Let’s say we are working on a blog website. We’re going to add a feature to the blog that lets users comment. We don’t want this feature to be part of the main version of our project because we are still working on it.

Get offers and scholarships from top coding schools illustration

Find Your Bootcamp Match

  • Career Karma matches you with top tech bootcamps
  • Access exclusive scholarships and prep courses

By continuing you agree to our Terms of Service and Privacy Policy , and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.

We can use a Git branch for this. We can create a branch called “comments” to store all the code for our commenting feature. This will let us work on our commenting feature without changing the main version of our codebase that is deployed on a website.

Branches can be stored locally or remotely. If you are working on a local version of a project, a branch will be local. Remote branches are stored with the main version of a project.

Git: Fetch All Branches

We’re working on a project called blog-site. This project contains two branches: origin master and origin dev.

The dev branch contains all the experimental features we are working with. We think that another collaborator has pushed changes to both branches. We want to make sure and retrieve the metadata for any changes if they have been made.

We can do this using the fetch command. The fetch command tells Git to retrieve metadata from a remote branch on the latest updates. The fetch command does not update the files stored in a local version of a repository.

To track all remote branches and fetch the metadata for those branches, we can use the git fetch command with the –all flag:

git fetch --all

This command returns:

Fetching origin
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
   3fcea0c..da74d68  dev    	-> origin/dev

The fetch command has fetched all of the changes we’ve made to our remote repository. The fetch command knows our remote dev branch contains changes we do not have on our local machine. We have just retrieved the metadata for those commits.

We can retrieve the metadata for an individual branch using the git fetch origin <branch-name> command.

Git: Pull All Branches

What if you want to update your local working copy as well as retrieve metadata? That’s where the git pull command comes in handy.

Venus, a software engineer at Rockbot

"Career Karma entered my life when I needed it most and quickly helped me match with a bootcamp. Two months after graduating, I found my dream job that aligned with my values and goals in life!"

Venus, Software Engineer at Rockbot

We now know that changes have been made to our repository. We are happy with merging these changes with our local repository. To download the changes to our local machine, we need to use the git pull command :

git pull --all

We’ve used the –all flag to indicate that we want to retrieve changes from every branch. Our command returns:

Fetching origin
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
   3fcea0c..da74d68  dev    	-> origin/dev
Updating 3fcea0c..da74d68
Fast-forward | 1 +
 1 file changed, 1 insertion(+)

The git pull command first runs a git fetch command to check for changes. The fetch operation returns the metadata for our commits . Then, the git pull command retrieves all the changes we have made to our remote repository and changes our local files.

We can see the file was changed on our remote repository. Now that we’ve run a pull operation, we have the change on our local machine.

To retrieve the code from one branch, we could use the git pull origin <branch-name> command.


The git fetch –all command retrieves metadata on each change made to all the branches in a repository. The git pull –all command downloads all of the changes made across all branches to your local machine.
Now you have the knowledge you need to pull all branches from Git like a pro !

About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.

What's Next?

James Gallagher

About the author: James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse,, Afrotech, and others.

Skip to main content