Skip to main content

Move private repos from Bitbucket to GitHub

0 min read (58 words)

Sidebar

Now that Github supports unlimited private repos in all plans, you might as well keep things all together (although definitely have backups elsewhere incase Github is DDOS'd again, dies or goes evil). Simply change "rubenwardy" to your username and "XXXX" to a [personal access token](https://github.com/settings/tokens) with "repo" checked. Also make sure you have an [SSH key](https://github.com/settings/keys) for Github.

Now that Github supports unlimited private repos in all plans, you might as well keep things all together (although definitely have backups elsewhere incase Github is DDOS’d again, dies or goes evil). Simply change “rubenwardy” to your username and “XXXX” to a personal access token with “repo” checked. Also make sure you have an SSH key for Github.

# Clone from bitbucket
git clone git@github.com:samkuehn/bitbucket-backup.git
mkdir bk
cd bitbucket-backup
./bitbucket-backup -u rubenwardy --mirror -l ../bk

# Upload to GitHub
cd ../bk
for D in *;
do
    echo $D
    cd $D
    data="{\"name\": \"$D\", \"auto_init\": false, \"private\": true }"
    curl -i -H 'Authorization: token XXXX' -d "$data" https://api.github.com/user/repos
    git push --mirror git@github.com:rubenwardy/$D.git
    cd ../
done
cd ../

Comments

Leave comment

Shown publicly next to your comment. Leave blank to show as "Anonymous".
Optional, to notify you if rubenwardy replies. Not shown publicly.
Max 1800 characters. You may use plain text, HTML, or Markdown.