GIT migration

From BitBucket 2 GitHub

Step 0: Update the GitHub migration sheet with the following details - ETA Dec 15th, 2022

  1. Make sure you have signed-up to https://github.com/kaleyra, if not reach out to IT

  2. Update the following details in the sheet here

    • BitBucket Repo name, URL

    • CodeOwner, Team-name, GitHub IDs of the developers who need write access

Step 1: DevOps will Create the repository on Github - ETA Dec 16th, 2022

  1. Based on the Step 0 Information DevOps will ensure the repos are present in GitHub, so that the dev can push the code changes from their local machine as per step 2

  2. To create the GitHub team with the specific Devs and Branch Protection rules.

Step 2 : Moving all code and content from bitbucket

  1. Each dev owners of the repos, Pull the latest code from BitBucket into your local machine either by git clone or git pull and add the "github" as an alternate remote.

    1. Option 1: If you do not have a local repo, here the vector repo is taken as example, you replace your respective repo name .

      
      git clone git@bitbucket.org:kaleyra/vector.git && cd vector && git remote add github git@github.com:kaleyra/vector.git 
    2. Option 2: You already have a BitBucket repo local copy

      cd vector 
      
      git pull && git remote add github git@github.com:kaleyra/vector.git

2. Now let's do little cleanup on the existing branches and standardise it

  1. Ensure that we have the standard branch names as. "master", "stage", "develop", all small cases. Incase in the existing BB repo, the branch names are either of the following, "Develop", QA, etc. You can map it correctly using the any of the (or) all of the following commands depending on the situation.

    • git checkout -b develop --track origin/Develop
      
      git checkout -b stage --track origin/QA 
  2. Now, as a next step, lets cleanup the existing unwanted repos before pushing to GitHub, the following command retains only "master", "stage" and "develop", all the remaining branches will be restricted from pushing to github.

    • git branch -r | grep origin/ | grep -v 'master$' 'develop$' 'stage$' | grep -v HEAD| cut -d/ -f2 | while read line; do git push github :$line; done;

      Note: if the removal of the branches are taking too much time, you can abort it by Ctl+C or Ctl+cmd

3. All done, let's push required branches and tags to GitHub Repository using below commands

git push --mirror github

git push --tags github

Step 3 : Add the CODEOWNERS

  1. Once the code is migrated to GitHub, you need to create a file at the root of the repo named "CODEOWERS", you may have to copy this file across required branches with either same or different reviewers. Below is the sample file.

$ # Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.

# More details are here: https://help.github.com/articles/about-codeowners/

# The '*' pattern is global owners.

# Order is important. The last matching pattern has the most precedence.
# The folders are ordered as follows:

# In each subsection folders are ordered first by depth, then alphabetically.
# This should make it easy to add new rules without breaking existing ones.

# Global rule:
*           @kaleyra/core

# Global rule, multiple teams:
*           @kaleyra/core, @kaleyra/core-sre

# Node# samples: Adding multiple individaul code reviewers
/bills/**  @Vijay, @peppe

# Specific Files
/bills/*yaml @Balu

# WPF folders:
/wpf/**   @adegeo

# Windows forms areas:
/windowsforms/** @adegeo @dotnet/dotnet-winforms

Step 4 : Update the existing jenkins git url

  1. SREs to update the git urls of the jobs to github

Last updated