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.
Templates
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
The following sections cover what is replicated when you clone the configuration or content, and how to use the script.
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
Note: 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 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.