How do I mirror a Bitbucket git repository to a local copy?

I have a few private Git repositories on Bitbucket that I need mirrored locally behind a firewall so we can use gerrit with them. The goal is that every time there is a push to the clone, the clone then pushes the new refs to bitbucket, and vice versa.

2 answers

1 accepted

1 vote
Answer accepted

Hi Andrew,

To mirror changes from Gerrit to Bitbucket, you could use replication.

To mirror changes from Bitbucket to Gerrit, there are a couple of different options. The easiest way would be to have a cron job or other scheduled task that polls the Bitbucket repository for changes and then updates your Gerrit repo. If you want to set up a more efficient "push" method, you'd need to configure a POST Hook on your Bitbucket repository that triggers some kind of web service that pulls the changes down and pushes them in to your Gerrit repository.

I wrote a little bit more about one way you could handle two-way mirroring in this answers post:



Thanks for the response. I'll try this out. Seems like the simplest would be a single cron job that runs the pulls and pushes in both directions. I might try that first to see if this works and doesn't create too much load on any servers before trying something more complex. I'll get back to you with my results.

I finally had a chance to try this out. I created a cron job that runs every few seconds and syncs the repos. Seems to work for now. Thanks for your suggestions.

I don't know anything about them, but you probably need to research "hooks".

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 14, 2019 in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

247 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you