Skip to content

Instantly share code, notes, and snippets.

@biggers
Created May 21, 2020 15:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biggers/e8eed7ba48038520c0cae92bee14d14d to your computer and use it in GitHub Desktop.
Save biggers/e8eed7ba48038520c0cae92bee14d14d to your computer and use it in GitHub Desktop.
Git, fetch all branches!
#!/bin/sh
# "git fetch all branches" -- to your local-repo
## to RUN-ME:
## git branch -r | sed -r -e 's:origin/::g' -e '/^\s+HEAD/d' | egrep -v gerrit/ > /tmp/foo
# ... gives you a chance, to change the "temp list of Branches to fetch"
## cat /tmp/foo ## hand-edit, if needed
##
## git-fetchall $(cat /tmp/foo)
echo "USAGE: git-fetchall branch branchN ..."
set -x
git fetch --all
for branch in "$@"; do
git checkout "${branch}" || git checkout -b "${branch}" || exit 1
# Pull the content. Set-up to track that remote-branch
git co "$branch" && git update-from origin $branch
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment