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

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: https://answers.atlassian.com/questions/325269/move-changes-from-disconnected-stash-repositories

cheers,

Tim

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

2,006 views 1 5
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