How to duplicate a Bitbucket Cloud repository
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
This guide provides step-by-step instructions for duplicating a Bitbucket repository to ensure complete independence from the original repository. Unlike forking, this method severs all connections with the source repository, allowing you to create a standalone copy while retaining complete control over the duplicated repository.
Duplicating a repository will only transfer the existing git data to a new one. All other metadata, such as repository settings, pull requests, pipelines builds, and others, will not be carried over.
Environment
- Bitbucket Cloud
Solution
There are two methods for accomplishing this:
Option 1 - Import repository via the UI importer
The prerequisites for this option are the workspace location ID, repository URL for duplication, and App password. Please follow the steps below:
- Log in to Bitbucket and navigate to the workspace where you want to duplicate the repository.
- Click on Create > Repository.
- In the top right corner of the form, choose Import repository, or access it directly using this URL: https://bitbucket.org/<WorkspaceID>/workspace/repository/import (Replace <WorkspaceID> with your destination workspace name).
- Complete the import form with the following details:
- The repository URL you intend to duplicate
- Your Bitbucket username
- Your App Password
- The workspace destination for duplicating the repository
- Choose the project
- The name for the duplicated repository
5. Once all information is filled in, click the Import repository button to duplicate the repository.
Option 2 - Clone and Push via CLI
The prerequisites for this option are the workspace ID, repository URL for duplication, and the new repository URL. Please follow the following steps:
- Clone the bare repository you want to duplicate locally:
Using HTTPS:
git clone --mirror https://<username>@bitbucket.org/<WorkspaceID>/<RepoName>.git
Using SSH:
git clone --mirror git@bitbucket.org:<WorkspaceID>/<RepoName>.git
- Create the duplicate repository placeholder in your destination workspace and save the URL.
- Navigate to the cloned bare repository on your local machine via CLI.
Perform a mirror push to the new repository in the destination workspace:
Using HTTPS :
git push --mirror https://<username>@bitbucket.org/<WorkspaceID>/<RepoName>.git
Using SSH:
git push --mirror git@bitbucket.org:<WorkspaceID>/<RepoName>.git
Remember to change the <username> for your Bitbucket username as well as the <WorkspaceID> and <RepoName>. Change the <WorkspaceID> to the new workspace name if the location is not within the same workspace.
If you encounter issues when following the instructions in this article, please raise a support ticket or raise a community support ticket for further assistance with this.