Skip to content

Instantly share code, notes, and snippets.

@sbatial
Last active February 28, 2020 13:44
Show Gist options
  • Save sbatial/9a2d24bbf6e804a3cd2de6e9fbec736d to your computer and use it in GitHub Desktop.
Save sbatial/9a2d24bbf6e804a3cd2de6e9fbec736d to your computer and use it in GitHub Desktop.
Push all branches in the current repo to Github
#!/bin/bash
while getopts r: option
do
case "${option}"
in
r) REPOSITORY=${OPTARG};;
esac
done
git remote add origin https://github.com/$REPOSITORY
for branch in $(git for-each-ref --format='%(refname:short)' refs/heads/)
do
git switch $branch
git push -u origin $branch
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment