# No More Manual Pulling: How to Automatically Pull All Git Branches from Remote to Local

## Problem

When you clone a repo to your local machine, it doesn't pull all the branches to your local. Then you have to manually pull the branches you want.

## Solution

To pull all the branches from the remote, run the following command

```bash
git branch -r | grep -v '\->' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
```

Done!

## Resources

* Stackoverflow solution: [https://stackoverflow.com/questions/10312521/how-do-i-fetch-all-git-branches](https://stackoverflow.com/questions/10312521/how-do-i-fetch-all-git-branches)
