Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Emuentes/65a5867c1e0898a359dc to your computer and use it in GitHub Desktop.
Save Emuentes/65a5867c1e0898a359dc to your computer and use it in GitHub Desktop.
Push all local branches to upstream origin -- handy when migrating to a new git host
# handy when migrating your local branches to a new git host
# git branch prints out each local branch on it's own line
# the grep command excludes the lines that end with master, develop, or HEAD
# it also excludes the currently checked out branch, which begins with an asterisk
# for example:
# if your git branch command returns the following:
# *develop
# master
# feature/new-button
# hotfix/update-link-href
# release/my-app-1.0.0
# the code below will run the following commands in this order:
# git push -u origin feature/new-button
# git push -u origin hotfix/update-link-href
# git push -u origin release/my-app-1.0.0
git branch | grep -v -E '(\*|master$|develop$|HEAD$)' | xargs -n 1 git push -u origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment