Skip to content

Instantly share code, notes, and snippets.

@kidmose
Created March 9, 2021 13:17
Show Gist options
  • Save kidmose/4c5ef87a19323957ef49ac67a281a1f7 to your computer and use it in GitHub Desktop.
Save kidmose/4c5ef87a19323957ef49ac67a281a1f7 to your computer and use it in GitHub Desktop.
Take a local cloned git repo, created it on github, and make sure all branches from the old origin is now on github
#!/usr/bin/env bash
git remote rename origin old
gh repo create $(basename $(pwd)) --private --confirm
git checkout master
git push -u origin master
for branch in $(git for-each-ref --format='%(refname:lstrip=-1)' refs/remotes/old \
| grep -v '^HEAD$' | grep -v '^master$' ); do
git checkout --track old/$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