Skip to content

Instantly share code, notes, and snippets.

@jordancrawfordnz
Created July 27, 2019 06:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jordancrawfordnz/87a2d9a3b6a6114e8b9b1a46e0fee3d2 to your computer and use it in GitHub Desktop.
Moving Git Repos from BitBucket to GitHub
OLD_REPO_NAME=[fill this in]
NEW_REPO_NAME=[fill this in]
USERNAME=[fill this in]
# Create the new repo in GitHub first.
# For all repos. This does a mirror clone so all references, tags, etc are migrated.
git clone --mirror git@bitbucket.org:$USERNAME/$OLD_REPO_NAME.git
cd $OLD_REPO_NAME.git
git push --mirror git@github.com:$USERNAME/$NEW_REPO_NAME.git
cd ..
rm -rf $OLD_REPO_NAME.git
# Include this for cloned repos only. This will update local references so you don't have to later.
git remote remove origin
git remote add origin git@github.com:$USERNAME/$NEW_REPO_NAME.git
git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment