A step-by-step guide for your company's Git master to main migration

栏目: IT技术 · 发布时间: 5年前

内容简介:The terms we pick for our tools matter, and our current default branch name ofHello @engineers! The terms we pick for our tools matter, and our current default branch name of

Migrating your default git branch to main

Jun 19 ·3min read

On Juneteenth, B12’s engineering team migrated its default git branch names to main , removing the problematic term master . Here’s the planning document we used, including internal messages and instructions for you to do the same.

Problem

The terms we pick for our tools matter, and our current default branch name of master is problematic. The word master is too closely related to the word slave , a practice that goes against B12’s values. For more information, see this helpful writeup from the IETF .

Slack announcement

Hello @engineers! The terms we pick for our tools matter, and our current default branch name of master is problematic. The word master is too closely related to the word slave , a practice that goes against B12’s values. What does this mean for you?

  • I tested a <repository name> conversion over the weekend with seemingly no impact on our infrastructure.
  • Over the course of the next week, we’ll convert the rest of our repositories.
  • You can find a full timeline of conversions here, along with the owner of the conversion: <link to the timeline section>
  • The <repository list> repositories are the most important ones to migrate carefully. These repositories have a lot of open PRs against master , which block us from being able to delete the branch. To get around this, we’ll freeze all merges to master on <day> at <time>. We’ll create a main branch that will serve as the default branch. You will have until <next day> at <time> to change any of your PRs’ base to main (in the PR, click Edit and select base: main ). Any open PR with a master base on <next day> at <time> will be closed. We will then delete master .
  • If you’d like to volunteer to convert a repository, add your username to the timeline along with the repository and a name.

How to convert a repository

The new name of our default branches will be main .

For any repository, here are the steps we’ll follow to migrate it (documented on <repository you tested it on>, which we’ll test for a week and then implement across our branches).

  • Grab the no_masters.sh script
  • Make sure the repository is in a clean state (i.e., on the latest commit of the main branch, a clean `git status`).
  • Make sure your Github token doesn’t end up in your bash history
    set +o history
  • Run the script
    ./no_masters.sh -u YOUR_USERNAME -o YOUR_ORGANIZATION -t THE_TOKEN main REPO_FOLDER/
  • Inevitably, master will be protected, and not get deleted. Head to https://github.com/b12io/REPO_FOLDER/settings/branches and replace it with main , and set main as a protected branch.
  • <someone should automate this, but it’s sort of rewarding to do manually :)> Edit every open PR to point at main by clicking its Edit button and selecting a new base.
  • Grep the codebase for master , and submit a PR that replaces it with main . In particular, deploy scripts and other functionality will require an update.
  • Head to https://github.com/b12io/REPO_FOLDER/branches and manually delete master .
  • Fix any issues that arise in continuous integration or other automation.

Timeline

Create as many bullets as you have repositories.

  • [owner name] repository name: date we’re converting

Thank you

Thank you to Margaret for getting the idea in my head, Hilary for pointing to a script, Adam for writing it, and Daniel and Nitesh for providing feedback on this document!


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

创业小败局

创业小败局

创业家、i黑马 / 时代华文书局 / 2014-8-1 / 42.00元

让别人的失败,成为你的成功之母! 《创业小败局》由徐小平、何伯权等六位经验丰富的业界大佬,从《创业家》五年来跟踪的数千个创业案例中,精心挑选而来。21个最具代表性的失败案例,每个案例都代表了一种最常见的失败规律,也基本上覆盖了当下中国创业浪潮中,最容易遭遇的创业陷阱。失 败是有规律的。有时候创业者的选择和 行为,必然会导致失败,但当事人却因为缺乏经验而没有察觉。比如在错误心态下引入错误的合伙......一起来看看 《创业小败局》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具