Process for repository with all branches and history from one workspace to another workspace
Asked by Harshavardhanreddy_D:

Dear All,

Trust you are doing well.  
**Problem statement:**  
We have a repository associated with ex-employee workspace name which is non-standard.  
We want to move it to customer/project specific workspace. In this scenario, we want to make sure no branches, history loss while copying/transfer/importing repository from source to target workspace. We want understand any risks involved during this process.  
**Common Risks:**  
1) bitbucket URL will be changed  
2) User groups and members won't be available in the target workspace  
I have below options in my mind at this moment from bitbucket documentation.  
**1) Transfer repository ownership:**  
<https://support.atlassian.com/bitbucket-cloud/docs/transfer-repository-ownership/>  
From this document, on high-level understand that it provides the steps to transfer the repository ownership from one workspace to another workspace.  
a) Is there any risks involved in this process such as history commit loss?  
b) Target workspace have all the admin access if the repository transferred from source workspace?  
c) Source workspace have no more access to repository after transfer accept by the target workspace owner?  
d) All the history and branches with commits will be moved to new/target workspace?  
e) The target workspace repository members can able to see the history commits as the old users who committed the code are no more available in the workspace?  
**2) Copy the repository from source workspace to target workspace:**  
a) Is there a way to copy the entire repository from source workspace to target workspace without any data loss?  
b) Can I get the process for the same?  
c) Any risks involved in this process except from common risks?  
**3) Import repository from one workspace to another workspace:**  
a) Is this process import all code base with branches and history from source workspace to target workspace?  
b) Is there any risks if followed this process?  
Please advise and appreciate if any thoughts.  
Thanks  
Harsha


Answers:
author: Theodora Boudale
body: Hi Harsha,

Thank you for reaching out.

Please see below my answers to your questions:

> 1) Transfer repository ownership:   
> <https://support.atlassian.com/bitbucket-cloud/docs/transfer-repository-ownership/>  
> From this document, on high-level understand that it provides the steps to transfer the repository ownership from one workspace to another workspace.  
> a) Is there any risks involved in this process such as history commit loss?

No commits are lost when you transfer a repository. All commits, branches, pull requests, etc will be available after you transfer the repo.

The only thing that doesn't get transferred is deployment variables, in case you use them with Bitbucket Pipelines. In this case, you can retrieve the values of the deployment variables before transfer, and then recreate them after you transfer the repo.

In case the repo uses Git LFS, it will not be possible to transfer it. See here for a workaround:

* <https://support.atlassian.com/bitbucket-cloud/docs/current-limitations-for-git-lfs-with-bitbucket/>

> b) Target workspace have all the admin access if the repository transferred from source workspace?

The admins of the target workspace will have admin access to the repo after it is transferred.

Any users or user groups with default ++project permissions++ to the project you will transfer will also get access.

If you want to add more users or user groups or check permissions after the transfer, you can do so from **Repository settings \> Repository permissions**.

> c) Source workspace have no more access to repository after transfer accept by the target workspace owner?

That is correct.

> d) All the history and branches with commits will be moved to new/target workspace

Yes, all history, commits, branches, and pull requests will be there after the transfer.

> e) The target workspace repository members can able to see the history commits as the old users who committed the code are no more available in the workspace?

The target workspace members will be able to see the repo, history, and commits if they have access via project permissions or if you add them to the repo (see my answer to 1 b).

It doesn't matter that the people who committed the code do not have access to the target workspace.

> 2) Copy the repository from source workspace to target workspace:  
> a) Is there a way to copy the entire repository from source workspace to target workspace without any data loss?

You can take a mirror clone of the repo with

```
git clone --mirror repo_url
```

Then create an empty repo on the target workspace (with no readme and no .gitignore file)  

Then push from the mirror clone to the newly created empty repo.  

This will create a copy with all branches and commits, but pull requests, any wiki or issue tracker won't be transferred.  

If the repo uses LFS, please check the documentation I shared in 1 a) for the steps you need to follow.

> b) Can I get the process for the same?

See my answer to 2 a)

> c) Any risks involved in this process except from common risks?

Pull requests, wiki, issue tracker, etc, won't be transferred.

The only risk I can think of is if you accidentally push to a different repo than the one you intended to.

> 3) Import repository from one workspace to another workspace:  
> a) Is this process import all code base with branches and history from source workspace to target workspace?

Yes, that is correct. All the branches and history are imported, but pull requests, issue tracker, wiki, etc are not imported.

> b) Is there any risks if followed this process?

No risks for the repo's source code, history, branches, and commits.

Please feel free to reach out if you have any further questions or concerns!

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud