Skip to content

Instantly share code, notes, and snippets.

@martip07
Forked from kostajh/migrate-bitbucket.sh
Created July 17, 2019 20:33
Show Gist options
  • Save martip07/02626c903c359fed5a5cd61ce89657e1 to your computer and use it in GitHub Desktop.
Save martip07/02626c903c359fed5a5cd61ce89657e1 to your computer and use it in GitHub Desktop.
Migrate repositories from gitolite (or somewhere else) to Bitbucket
#!/bin/bash
# Usage: ./bitbucket-migrate.sh repos.txt
#
# repos.txt should have one repository per line.
echo "Reading $1"
while read line
do
repo=$line
echo "###"
echo "Processing $repo"
git clone --bare git@git.designhammer.net:$repo
cd $repo.git
echo "Creating repo in Bitbucket"
curl --user USER:PASSWORD https://api.bitbucket.org/1.0/repositories/ --data name=$repo --data is_private=true --data owner=designhammer
echo "Pushing mirror to bitbucket"
git push --mirror git@bitbucket.org:designhammer/$repo.git
cd ..
echo "Removing $repo.git"
rm -rf "$repo.git"
echo "Waiting 5 seconds"
echo "###"
sleep 5;
done < $1
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment