Skip to content

Instantly share code, notes, and snippets.

@adityapatadia
Created April 24, 2024 17:13
Show Gist options
  • Save adityapatadia/0ea8f49878ce758b59f30973d400ef91 to your computer and use it in GitHub Desktop.
Save adityapatadia/0ea8f49878ce758b59f30973d400ef91 to your computer and use it in GitHub Desktop.
Bitbucket to Github migration script
###############Shell script for migrating all repo’s reading from file################
#!/bin/bash
name_of_github_org=yourorg
while IFS="" read -r p || [ -n "$p" ]
do
git clone --bare $p;
repo=`echo "$p" | cut -d "/" -f 2`
echo "Local repo created: $repo"
cd ${repo}.git
gh repo create ${name_of_github_org}/${repo} --private
git push --mirror [email protected]:${name_of_github_org}/${repo}.git
cd ..
done < bitbucket.txt
@adityapatadia
Copy link
Author

Steps:

  1. Create bitbucket.txt file which lists all repos
  2. Setup SSH authentication for both Github and Bitbucket so you can do git clone on Bitbucket and git push on Github
  3. Setup gh command line: https://cli.github.com/

That's it. The script will migrate all repos one by one. Tested on MacOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment