Can you migrate all the branches in a repo from bitbucket server to bitbucket cloud?

We are looking at switching from using bitbucket server to bitbucket cloud.  We have been able to migrate only the master branch of a repository in our prototype.  

Is it possible to migrate all the branches?   What are the steps?

We also do not see a way to migrate pull requests.  Is it possible?

Thanks!

KL

1 answer

Bitbucket can be viewed as just another remote Git repository, so ensure that you have the latest commits on your local repository and then add your bitbucket.org repo as another remote and use standard git commands to push all the branches.

Unfortunately it is not yet possible to import pull requests (see latest comments on BSERV-3555).

Personally, I prefer to do this via "git clone --mirror" followed with a "git push --mirror" instead of adjusting my remotes.

The "git clone --mirror" will tantalizingly grab a bunch of internal "pull" refs, but they're of no use.  Like Gareth Cantrell said, you can't actually migrate the pull requests.   So instead I just clean them out before pushing to the new git server.

Here's the actual commands I type:

git clone --mirror [original-clone-url]
cd [original-clone]
git for-each-ref --format='%(refname)' 'refs/pull-requests/'  | xargs -l  git update-ref -d
git push --mirror [new-clone-url]

 

When migrating FROM Bitbucket Server you need to clean out all refs under "refs/pull-requests/".   When migrating FROM Github, the refs are under 'refs/pull/'.  And so adjust the commands above to suit the situation.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,774 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you