Skip to content

Instantly share code, notes, and snippets.

@msiegenthaler
Created April 10, 2013 18:50
Show Gist options
  • Save msiegenthaler/5357360 to your computer and use it in GitHub Desktop.
Save msiegenthaler/5357360 to your computer and use it in GitHub Desktop.
Import a whole directory structure of GIT repositories into bitbucket.
require 'find'
base = '/your/repostructure/root'
repo = 'you' # Bitbucket user
user = 'you'
pass = 'pass'
Find.find('../gits') do |path|
if File.basename(path) == '.git'
gitpath = File.dirname(path)
name = gitpath.sub(base, '')
print "Migrating repo #{name}\n"
Dir.chdir(gitpath) {
`curl --user #{user}:#{pass} https://api.bitbucket.org/1.0/repositories/ --data is_private='true' --data name='#{name}'`
`git remote add origin ssh://git@bitbucket.org/#{repo}/#{name.tr('/','-')}.git`
`git push -u origin --all`
}
print "Migrated repo #{name} to bitbucket\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment