Created
April 10, 2013 18:50
-
-
Save msiegenthaler/5357360 to your computer and use it in GitHub Desktop.
Import a whole directory structure of GIT repositories into bitbucket.
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
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://[email protected]/#{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