Skip to content

Instantly share code, notes, and snippets.

@grimzy
Created September 15, 2017 02:15
Show Gist options
  • Save grimzy/a1d3aae40412634df29cf86bb74a6f72 to your computer and use it in GitHub Desktop.
Save grimzy/a1d3aae40412634df29cf86bb74a6f72 to your computer and use it in GitHub Desktop.
Git pull all remote branches
#!/usr/bin/env bash
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
@m3asmi
Copy link

m3asmi commented Jul 13, 2022

@jcwren thanks, I fixed it

@CynCity17
Copy link

This was so helpful! Thank you!

@haiderGithubOfficial
Copy link

haiderGithubOfficial commented Nov 23, 2023

great

@hughesjs
Copy link

hughesjs commented Dec 8, 2023

Going to come in with a controversial new option:

git branch --remote | cut -c 10- | xargs -d\\n -n1 git switch -f

Just make sure you've committed or stashed all of your changes. This does assume that your remote is called origin, if it's not, change the number of digits getting slashed by cut.

@andry81
Copy link

andry81 commented Dec 30, 2023

Mine own approach to pull and sync:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment