Better Programming

Advice for programmers.

Follow publication

Member-only story

A BitBucket CI/CD Pipeline to Sync Branches With GitHub

Albin Issac
Better Programming
Published in
5 min readDec 3, 2020
Waves washing up on shore
Photo by César Couto on Unsplash.

Most of the time, we will have a requirement to sync branches between two different repositories (e.g. BitBucket repository to GitHub repository).

This is a common scenario when working on a cloud repository, but the day-to-day development is managed through local repositories. In that case, the local repository branches should be synced to the cloud repository for deployment. Handling the sync manually creates a lot of issues and also consumes more time from the development team. The better option is to automate the branch sync between the local repository and cloud repository. Complete repository mirroring can be enabled, but that will sync every branch. My aim is to sync only specific branches.

Diagram of pipeline to sync branches
Photo by the author.

In this tutorial, we’ll see an approach to sync the branches between a BitBucket repository and GitHub through a BitBucket CI/CD pipeline. The same approach can be followed with minimal changes to sync the branches of any two repositories.

Prerequisites

  • Bit Bucket repository
  • Empty GitHub repository

Set Up Bitbucket Pipeline

I have created a branch with the name dev in the BitBucket repository. The dev branch should be synced with the GitHub repository on any changes. The dev branch will be created in the GitHub repository during the first sync.

The pipeline will be executed on every change pushed into the specified branches (e.g. dev and sync the changes with the remote GitHub repository).

Log in to the BitBucket repository, click on “Pipelines,” and click on “Create your first pipeline”:

Creating a pipeline

Select “Starter pipeline”:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Albin Issac
Albin Issac

Written by Albin Issac

I work as a Software Architect specializing in Marketing Technologies. For more information, please visit my profile at: https://myprofile.albinsblog.com/

Responses (3)

Write a response