Skip to main content

Command Palette

Search for a command to run...

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

Updated
1 min read
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

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