Last active
January 11, 2019 07:34
-
-
Save mhulse/6e32f1a5b403ec8438186f52e9bfc3c6 to your computer and use it in GitHub Desktop.
Simple script to transfer multiple repos from Bitbucket to GitHub (or vice versa). Inspired by https://stackoverflow.com/a/21260628/922323
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This script assumes you have your ssh keys setup for Bitbucket and GitHub. | |
# It also assumes you have created the repos on GitHub already and the URL slugs are an exact match. | |
# Also, this script will barf if you try to transfer an empty repo. | |
# Note that this code does not transfer wikis, downloads or issues. | |
# Also note, you may have to turn on QOS upload speed limiting so your router | |
# doesn’t freak out; I limited my upload bandwidth to 2Mbps. | |
# Don’t forget to `chmod u+x <this file>.sh` in order to execute it via `./<this file>.sh`. | |
declare -r bitbucket_user= | |
declare -r github_user= | |
declare -r xfer_from=bitbucket.org | |
declare -r xfer_to=github.com | |
# Explicitly declare a variable (this is better than implicit): | |
declare -a repos=( | |
"foo" | |
"baz" | |
"bar" | |
"other" | |
) | |
for i in "${repos[@]}"; do | |
echo Transfering repo: "$i" | |
git clone --bare git@${xfer_from}:${bitbucket_user}/${i}.git | |
cd ${i}.git || exit | |
git push --mirror git@${xfer_to}:${github_user}/${i}.git | |
cd - || exit | |
done | |
# Gracefully Exit program: | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment