Clone Repository

With the Clone repository built-in script, you can clone the content of a repository, and/or clone the repository configuration, including permissions, hooks, and the branch model.

  • If you select to only clone the configuration, it will clone the configuration of an existing repository into a new uninitialized repository.
  • If you select to only clone the content, it will create a clone of the source repository, applying the default configuration.

By cloning the configuration, you can create new repositories and ensure the correct settings are applied, or duplicate a complex configuration quickly.

In Bitbucket 5.2.0+ if the existing repository inherits particular configuration items from the project then the  Target Project Settings are inherited for the cloned repository.


Having the option to clone the repository configuration and the content is useful when you need to generate new repositories with a consistent structure or setup. You can use any existing repository as a template to quickly and easily create new repositories that adhere to any standards you have in your organization.

Cloning the repository

What items are replicated when you clone the configuration?

The following configuration items are replicated in the new repository:

  • Repository permissions, including whether the source repository is publicly accessible and forkable

  • Branch permissions

  • Enabled hooks settings

  • Branch model

    If you clone the configuration and do not clone the repository content, then the branch model is only partially copied, as you cannot set some of the branch model's settings until the branch exists, such as the production branch. The branch model is fully copied if you clone both the configuration and the content.

  • Pull request settings (those that are shipped with Bitbucket)

    • Minimum number of approvals

    • Require all tasks to be resolved (useful in conjunction with adding default tasks to new pull requests)

    • Minimum number of successful builds

    • Require all reviewers to approve the pull request

    • Enabled merge strategies and default merge strategy

  • ScriptRunner features

    • Pre hooks

    • Post hooks

    • Merge checks

    • Listeners

What items are replicated when you clone the content?

If you choose to clone the content of a repository you have two options:

  • Clone all branches and tags (with commit history). This option clones every branch and tag from the template repository, retaining the full commit history. This creates a new repository that contains a full copy of each commit from the source.

  • Clone all branches (without commit history). This option clones all branches from the source repository but resets the commit history, so each branch contains one initial commit.

The Do not clone content option is meant to be used if you only want to clone the configuration, and start with an empty repository. If you select this option and have not chosen to clone the configuration, the script will not execute, and no repository is created as there is nothing to copy from the source repository.

LFS repositories

The Clone content option does not support LFS repositories. You can still clone LFS-enabled repositories, but this feature will not clone the content that is stored in LFS. Instead, it will copy all the content that is not stored in LFS, and the LFS references. You must enable and set up LFS storage manually for the new repository.

Using this built-in script

  1. Navigate to ScriptRunner for Bitbucket > Built-in Scripts.
  2. Select Clone repository.
  3. Choose a Source repository. This is the repository you would like to clone. 
  4. Select if you would like to clone source repository configuration.
  5. Choose a Clone content option.

    You can not choose the Do not clone content option if you have not selected to clone the source repository configuration.

  6. Enter a name for the target repository. This is the name of the cloned repository that will be created. 
  7. Select Run.
On this page