Keeping a non-1:1 mirror in sync and keeping private branches
- Date: Sun, 16 Jul 2017 02:59:23 +0200
- From: Jan Danielsson <jan.m.danielsson@xxxxxxxxx>
- Subject: Keeping a non-1:1 mirror in sync and keeping private branches
Let's say there'a s hosting service hosting a repository which I want
to self-host. I don't just want to do a mirror, but I want to keep it
in sync (using a cronjob). In addition, I want to have private branches
on the self-hosted repository. (In this particular case, the "hosting
service" is github, and "self-hosting" is bitbucket -- but I'm looking
for a solution which is agnostic with regards to hosting service(s)).
Searching, reading and asking around led me to the following (these
are scripts which are run on a separate system which acts as a git bridge):
git clone --mirror $UPSTREAMURL $DSTDIR
git remote rename origin upstream
git config remotes.default 'upstream'
git remote add --mirror=push origin $DOWNSTREAMURL
And then to keep self-hosted repository in sync with upstream:
git remote update --prune
This seems to accomplish everything I want except that the the "git
push" deletes any branches I have created on my self-hosted repository.
Am I doing it completely wrong? If not, how do I make my branches
survive the push?