Skip to content

Instantly share code, notes, and snippets.

@dexterous
Last active March 26, 2018 20:39
Show Gist options
  • Save dexterous/1245332 to your computer and use it in GitHub Desktop.
Save dexterous/1245332 to your computer and use it in GitHub Desktop.
Migrating a repo to GitHub
cd path/to/git/repo
git remote add github [email protected]:${user_or_org}/${repo}.git
git remote rename origin old
for b in `git branch -r --no-color | cut -b3- | grep --color=none '^old/' | grep -v '/HEAD ' | cut -d '/' -f2`
do
git push github old/$b:refs/heads/$b
done
git push --tags github
git remote rename github origin
git remote rename origin old
git remote add github [email protected]:${user_or_org}/${repo}.git
for b in `git branch | cut -b3-`
do
git branch --set-upstream $b github/$b
done
git remote rename github origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment