I'm trying to sync our repository on Bitbucket with a fresh repository on Github, such that when I push code to origin (Bitbucket), it pushes that commit on to the "mirrored" Github repository.
To do this, I created the Github repo and set up the ssh keys etc.
I then added a Pipleline to Bitbucket called bitbucket-pipelines.yml
which has the following code:
clone:
depth: full
pipelines:
default:
- step:
script:
- git push --mirror git@github.com:orgname/nameofrepo.git
This brought over every commit and tag and the branch which I was currently on, but it did not bring over the other branches.
I suspect it has something to do with the fact that they all start with the word origin
, but that is just a theory based on the fact that the only branch which did come across did not start with origin
.
I've also tried a variation where I use:
- step:
clone:
depth: full # want all so can push all (maybe can optimise this in future?)
name: 'Sync push on branch to github'
script:
- git remote add sync git@github.com:orgname/nameofrepo.git
- git push sync --all --force
- git push sync --tags --force
Exact same result.
This is what other people (on blogs etc) have been doing to achieve this and I'm assuming they are trying to sync more than just main
.
Can anyone spot what I am doing wrong?