Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to migrate from bitbucket to stash

David Kunkel February 19, 2013

We are currently using BitBucket and want to move our repositories to Stash.

3 answers

1 accepted

5 votes
Answer accepted
Alexey_Efimov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 20, 2013

It documented on Atlassian Docs:

https://confluence.atlassian.com/display/STASH/Importing+code+from+an+existing+project#Importingcodefromanexistingproject-MirroranexistingGitrepository

It is significat to make Bare clone, not simple Copy clone. Because if you make not a Bare mirror, you get no remote branches. And push --all will not work fine.

I used follow commands to completelly migrate from one Git to another, this will copy anything:

git clone --bare git@bitbucket.org:/login/myrepo.git
cd myrepo.git
git push --mirror git@stash.acme.com:/project/myrepo.git
cd ..
rm -rf myrepo.git

In this solution you no need to add remote.

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 20, 2013

Thanks Alexey. You're quite right - that's actually a better way to do it.

AndyM April 17, 2013

Wouldn't it be better to mirror the clone at the first step?

git clone --mirror git@bitbucket.org:/login/myrepo.git

Also, is the process repeatable if commits are made to the Bitbucket repo?

1 vote
Dharmendra Verma May 30, 2013

Here is a python script to do this for you.

https://github.com/dkvermavit/git-server-backup-script

0 votes
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 19, 2013

Hi David,

I guess this depends on how many repositories you have to migrate? If we're talking 5-10, then frankly I would just do it manually for now.

If you have more thant that it might be worth thinking about writing a script (which we could definitely help with). You could use both the REST endpoints to query the Bitbucket repositories and re-create them in Stash.

Cheers,

Charles

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 20, 2013

Not specifically. It's really just the normal Stash documentation you might want to take a look at:

https://confluence.atlassian.com/display/STASH/Stash+Documentation+Home

For each repository in Bitbucket you will want to clone the repository to a machine, create a matching repository in Stash and then push all the branches/tags. Something like:

git clone git@bitbucket.org:project/repo-name.git
cd repo-name
git remote add stash ssh://git@server:7999/PROJECT/repo-name.git git push --all stash && git push --tags stash

You may then also want/need to setup user permissions on your projects as appropriate to your organization.

I hope this helps?

Charles

David Kunkel February 20, 2013

Hi Charles,

Is there some documentation somewhere on how to do this manually?

Thanks,

Dave

David Kunkel February 24, 2013

Thanks for everyone's help - I'll get started with the migration today.

Dave Kunkel

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events