Mirror Repositories
You can mirror repositories of a particular user or organization/group in GitHub, GitLab, and/or Bitbucket.
You can mirror repositories to ensure that you are not dependent on a remote version control service being available at all times and to continue your build and release process even in the event of a denial of service attack (or similar).
- Bitbucket Cloud — "team"
- Bitbucket Server — "project"
- GitLab — "project"
- GitHub — "organization"
When a remote repository is mirrored, the local repository mirror is kept up-to-date when changes are made to the remote repository. This happens in one of the following ways:
- Installing a web hook into each remote repository. Then, the repository is updated when changes are pushed to the local Bitbucket repository.
- Polling the remote repositories for changes every five or thirty minutes.
Once the mirroring process has begun, you cannot push to the local Bitbucket repository. The remote repository is assumed to be authoritative and removes any branches in the Bitbucket repository that do not exist in the remote repository.
If the default branch is modified on both sides, synchronisation is broken. Remove the Bitbucket repository, and then rerun the setup.
A pre-receive hook is automatically setup for the mirrored repository to block all changes to the local Bitbucket repository.
If you want to push changes to the local Bitbucket repository, select the Remove option from View and Configure Mirrored Repositories.
Mirroring Repositories
Security
If you are using web hooks for synchronization, GitHub calls a REST endpoint in your Bitbucket instance when it's pushed to. To know that it's GitHub that's calling, the payload of the call is hashed with a secret token that you supply.
Follow these steps to generate a random token:
If you already have remote repositories that are synced by web hooks, you need to update these hooks, by rerunning this script.
http.proxyHost and http.proxyPort. However, you must change your .gitconfig on the Bitbucket server to specify the proxy. There is useful information here on how to set a proxy only for certain sites: http://stackoverflow.com/questions/16067534/only-use-a-proxy-for-certain-git-urls-domains. Currently, authenticated proxy access is not supported. Currently, authenticated proxy access is not supported.
View and Configure Mirrored Repositories
You can view the status of your mirrored repositories and projects, and you can modify the remote sync options.
You can check whether your Bitbucket repository is up to date with the remote repository by clicking the Check or Check All links.
If you previously set that repositories are automatically created, the projects set to do that are listed below the repositories. If you wish to stop this, check the checkbox under Stop Synchronization, and then click Run.
To change the regular expression, delete the configuration as shown below and then recreate the configuration. It's fine to mirror into existing repositories, and this should not take very long.