I have the requirement of copying the bitbucket project from location X to another location Y
Asked by chandreddy:

I have the requirement of copying the bitbucket project from location X to another location Y by retaining all the commit history from source location X. Please advise.


Answers:
author: Caroline R
body: Hi, [@chandreddy](/t5/user/viewprofilepage/user-id/4521131)! Welcome to the community!

If you have administrative rights to this repository, you can change or [transfer the ownership of the repository](https://support.atlassian.com/bitbucket-cloud/docs/transfer-repository-ownership/) to another workspace. The transferred repository comes with its commit history and wiki, but it will lose the access groups and won't inherit the destination account's default access groups. You'll have to set those on the repository after the transfer.

In order to **transfer the repository ownership**, you can follow the next steps:

* Access the repository you want to transfer \> click **Repository settings** in the left menu.

* Select the option **Manage repository** \> click **Transfer repository**.

* Enter the **Workspace ID** of the workspacein which you want to transfer the repository.

* Click **Transfer.**

* Then, Bitbucket will send an email to the new owner or workspace administrators containing the transfer request with a link to the page that allows the user to accept or reject the transfer.

Please let us know if you have any questions about this process.

Kind regards,  
Caroline

comments: author: chandreddy
body: Thanks [@Caroline R](/t5/user/viewprofilepage/user-id/3934006) . Do old repository remains or does it gets deleted? I want to keep old one without deleting.


author: Theodora Boudale
body: Hi [@chandreddy](/t5/user/viewprofilepage/user-id/4521131),

Please allow me to step in here as Caroline is out of office.

If you transfer a repository, it will ++not++ remain in the original workspace.

Just to make sure I understand your requirements, when you say "copying the bitbucket project from location X to another location Y", by "location" you mean another Bitbucket workspace?

If so, then I can suggest two different options:

**1.** You can fork the repository to the same or different workspace

* <https://support.atlassian.com/bitbucket-cloud/docs/fork-a-repository/>

While viewing the repository on Bitbucket website, select the **Source** page, then select the 3 dots near the top right corner (next to the option **Clone** ) \> **Fork this repository**.

This option will be visible if forking is allowed for this specific repo.

The fork is linked to the original repo, so you have the option to sync it with the original one when more commits are made to it, and you can also create PRs from the fork to the original repo.

**2.** If syncing the two repos or creating PRs is not a requirement, you can also do the following:

* Take a mirror clone of the repo with the command

```
git clone --mirror <repo-url>
```

* Then, create an empty repository in Bitbucket Cloud
* Push from that mirror clone to the newly created empty Bitbucket repo:

```
git push --mirror <url-of-the-new-empty-repo>
```

Please feel free to let us know if you have any questions.

Kind regards,  
Theodora


author: chandreddy
body: [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) Thank you very much for your reply. Just to clarify for both the options will have commit history from the original repo right?


author: Theodora Boudale
body: Hi [@chandreddy](/t5/user/viewprofilepage/user-id/4521131), you are very welcome, and to answer your question, yes, indeed.

With both options, all the commit history of the original repo will be copied to the new repo.

Please feel free to let us know if you have any questions when you try this.


author: chandreddy
body: [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) Thanks. Can I also assume that mirror would also copy all branches feature, master etc would also be copied from the original repo?


author: chandreddy
body: [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) never mind, I tried mirror and all branches got copied along with history. Thanks heaps both [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) and [@Caroline R](/t5/user/viewprofilepage/user-id/3934006) for your help on time.


author: Theodora Boudale
body: Hi [@chandreddy](/t5/user/viewprofilepage/user-id/4521131),

You are very welcome, we're glad to have helped.

The purpose of the --mirror flag in the clone command is to get all branches, if you do a 'git clone' without --mirror then you get locally only the main branch of the repo.

It's good to hear that you figured this out, if you ever need anything else, please feel free to reach out!

Kind regards,  
Theodora


author: chandreddy
body: Hi [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) and [@Caroline R](/t5/user/viewprofilepage/user-id/3934006)

After copying the old repo to new repo using Mirror option, some how both old and new repo are in Sync. That means all the commits that are done in new repo can also be seen and accessed in old repo. Having said this, we are not sure what is the impact if we try to delete the old repo that might cause everything gets deleted in new repo as well. Looks like they are in sync both ways?

I thought Mirror option does not do the sync of the both repos. I don't want to keep both in sync. Please advise.


author: chandreddy
body: Hi [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) and [@Caroline R](/t5/user/viewprofilepage/user-id/3934006) ,

I was able to fix the issue by updating the SCM properties in pom.xml to point to new repo and now problem is solved. On another note, I need to copy some of the tags from old repo to new repo is that possible and how?


Tags: bitbucket-cloud

cloud

copy