Skip to content

Instantly share code, notes, and snippets.

@michrome
Last active May 15, 2019 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save michrome/6008805 to your computer and use it in GitHub Desktop.
Save michrome/6008805 to your computer and use it in GitHub Desktop.
Add these to your .profile to allow you to pull and push all your branches with a remote Git server.
# Usage:
# `git-pull-all` to pull all your local branches from origin
# `git-pull-all remote` to pull all your local branches from a named remote
function git-pull-all() {
START=$(git symbolic-ref --short -q HEAD);
for branch in $(git branch | sed 's/^.//'); do
git checkout $branch;
git pull ${1:-origin} $branch || break;
done;
git checkout $START;
};
function git-push-all() {
git push --all ${1:-origin};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment