[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-11。"],[],[],null,["# Mirroring a Bitbucket repository\n\nThis topic describes how to mirror a Bitbucket repository to\nCloud Source Repositories. With this configuration, commits that you push to the\nBitbucket repository are copied, or *mirrored*, into a repository hosted in\nCloud Source Repositories.\n\nOnly Bitbucket Cloud and GitHub Cloud repositories can be mirrorred to\nCloud Source Repositories; self-hosted Bitbucket and GitHub mirroring are not\nsupported.\n\nIf you are mirroring your Bitbucket repository to Cloud Source Repositories to integrate\nwith Cloud Build and do not need any other Cloud Source Repositories features,\nfollow the Cloud Build instructions on\n[building repositories from Bitbucket Cloud](/build/docs/automating-builds/build-repos-from-bitbucket-cloud)\ninstead.\n\nBefore you begin\n----------------\n\nWhen you mirror a repository, you must provide Bitbucket authentication\ncredentials. These credentials let Cloud Source Repositories access the\ncontents of the Bitbucket repository.\n\nIt is recommended that you [create a Bitbucket account](https://guides.co/g/bitbucket-101/11151)\nthat is specifically dedicated to automated tasks, such as mirroring a\nrepository. This account must have administrative access to your repository.\n\nMirror a Bitbucket repository\n-----------------------------\n\nThis section shows how to mirror a Bitbucket repository to\nCloud Source Repositories.\n| **Note:** Make sure you're signed out of Bitbucket before you mirror a repository. Signing out helps ensure you select the right Bitbucket account when you connect the Bitbucket repository to Cloud Source Repositories.\n\n### Create a mirrored repository\n\nIn this process, you need your Bitbucket machine user credentials to grant\nGoogle Cloud read access to the Bitbucket repository.\n\n1. In the Google Cloud console, open Cloud Source Repositories.\n\n [Open Cloud Source Repositories](https://source.cloud.google.com/repos)\n2. Click **Add repository**.\n\n The **Add a repository** page opens.\n3. Select **Connect external repository** and click **Continue**.\n\n The **Connect external repository** page opens.\n4. In the **Project** drop-down list, select the Google Cloud project to\n which the mirrored repository belongs.\n\n If you don't have a project, you can click **Create project** to\n [create a project](https://cloud.google.com/source-repositories/docs/creating-an-empty-repository#creating_a_project).\n5. In the **Git provider** drop-down list, select **Bitbucket**.\n\n6. Select the checkbox to authorize Cloud Source Repositories to store your\n credentials.\n\n7. Click **Connect to Bitbucket**.\n\n8. Sign in to Bitbucket with your machine user credentials.\n\n9. Click **Authorize GoogleCloudPlatform**.\n\n This option grants Google Cloud read access to your repository.\n\n When authorization finishes, you're returned to the **Connect external\n repository** page. A list of repositories opens.\n10. From the list of repositories, select the repository you want to mirror.\n\n11. Click **Connect Selected Repository**.\n\n The main repository page opens. This page contains a list of the\n repositories for this Google Cloud project, including the new\n repository you just created.\n\n### Identify Bitbucket repositories\n\nCloud Source Repositories makes it clear which of your repositories are\nmirrors of Bitbucket repositories:\n\n- Each Bitbucket repository is represented with the Bitbucket logo.\n- The name of the repository has `bitbucket_` added to the beginning of its name.\n\nUpgrade a Bitbucket connection\n------------------------------\n\nIf you mirrored a Bitbucket repository by using an earlier\nGoogle Cloud console interface, Cloud Source Repositories prompts you to\nupgrade when you access your mirrored repository in the current\nGoogle Cloud console. Until the upgrade is completed, these prompts occur each\ntime you access the repository.\n\nYou must have the Source Repository Administrator role to upgrade the\nconnection. Upgrading the connection doesn't change the mirroring behavior of\nthe Bitbucket repository.\n| **Note:** Make sure you are signed out of Bitbucket before you upgrade the connection. This helps ensure you can select the right account when you connect the repository to Cloud Source Repositories.\n\n1. In the Google Cloud console, open Cloud Source Repositories.\n\n [Open Cloud Source Repositories](https://source.cloud.google.com/repos)\n2. Navigate to the mirrored Bitbucket repository.\n\n3. When prompted, click **Upgrade Credentials** to upgrade your connection.\n\nForce a repository sync\n-----------------------\n\nAfter you set up mirroring, Cloud Source Repositories automatically syncs\nyour repository with the mirrored repository when a user commits a change.\nCloud Source Repositories lets you to view the last time your mirrored\nrepository was synced and manually force a sync if necessary.\n\n1. In the Google Cloud console, browse to the mirrored Bitbucket repository.\n\n2. Click\n **Settings** *settings*.\n\n The sync status is displayed.\n\n3. To manually force a sync of the repositories, click **Sync from Bitbucket**.\n\n| **Note:** Repositories connected using an older version of the connected repository service may not have these options."]]