Mirror (SYNC) Bitbucket Repository to GitHub Repository.
For the project I’m working on we use GitHub. Recently new satellite app was developed by an external team, and this team uses Bitbucket. It would be nice to have sources synchronized to our GitHub organization so we can have a central place for all of it.
Repo mirroring can be accomplished using Bitbucket pipelines. It is relatively easy to set up mirroring using SSH key profiled as deployment key with write access on GitHub.
- On GitHub, create new repository.
- In Bitbucket repository, create
clone: depth: full pipelines: default: - step: script: - git push --mirror email@example.com:YourOrg/mirror-repo.git
- Commit pipeline file. This will run pipeline and fail (yet).
- On Bitbucket, go to the repository’s Settings / SSH keys and generate a new SSH key. Copy resulting public key to clipboard.
- In Known Hosts section on the same page enter
- On GitHub, in repository settings add a deployment key (Settings / Deploy Keys) granting write permission, and add the public key generated in Bitbucket.
- Now on Bitbucket go to pipelines and re-run failed sync pipeline. This time it should succeed.
Now on every push BitBucket will mirror changes to your repo.