I'm following this guide to setup a mirror from my private Bitbucket repo to a private Github repo.
https://medium.com/@dmitryshaposhnik/sync-bitbucket-repo-to-github-669458ea9a5e
Basically the guide involves setting up a bitbucket pipeline as follows:
clone:
depth: full
pipelines:
default:
- step:
name: 'Mirror to Github repo....'
script:
- git push --mirror git@github.com:my-repo/repo.git
I have it (kinda) working, but the pipeline fails due to the following:
: [remote rejected] master (refusing to delete the current branch: refs/heads/master)
So it looks like the git push --mirror
command first deletes all branches, is that correct?
I understand why the master delete won't work (not allowed unless it's an github admin) and I don't want to change the master etc.
I simply want to pipeline all git events on the bitbucket repo over to the github repo.
Anyone know how to do this without hitting this issue?
Separately, I know I could do this by adding another remove to the repo locally and then pushing from there, but I'm looking for a solution that can be handled server side to make it simple for the rest of my team to not have to start manually adding second remotes etc.
You need to do the following:
default:
- step:
name: 'mirror repo'
script:
- git clone --mirror "${BITBUCKET_GIT_SSH_ORIGIN}" ./mirrored;
- cd ./mirrored;
- git fetch -p --tags origin;
- git push --mirror "git@github.com:you/target-repo.git"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.