Created
May 21, 2020 15:10
-
-
Save biggers/e8eed7ba48038520c0cae92bee14d14d to your computer and use it in GitHub Desktop.
Git, fetch all branches!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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