Mirroring Git repository from Bitbucket to Github
Steps
- On GitHub, create a new repository (import or from scratch).
- On Bitbucket, Enable Pipelines under Repository settings > Pipelines > Settings.
- On Bitbucket, Generate keys under Repository settings > Pipelines > SSH keys. Copy the public key to clipboard.
- On the same page, under Known hosts enter
github.com
as the Host address and then click Fetch* followed by Add host.
- On GitHub, add the public key under Settings > Security > Deploy keys > Add deploy key. Tick the checkbox to Allow write access.
- On Bitbucket, add the public key under Repository settings > Security > Access keys > Add key.
- Inside the Bitbucket repo, create a
bitbucket-pipelines.yml
file containing the following:
pipelines:
default:
- step:
name: Sync GitHub Mirror
image: alpine/git:latest
clone:
enabled: false
script:
- git clone --bare git@bitbucket.org:RepoOrg/RepoName.git
- cd RepoName.git
- git push --mirror git@github.com:RepoOrg/RepoName.git
See also