Skip to main content

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

Published 1 min readMarkdown
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

About the author

  • I'm an engineering senior at National Institute of Technology, Srinagar, India. I'm a developer, fitness aficionado, productivity enthusiast and a fellow nerd.

No comments yet. Be the first to comment.