🚛

GitHub のデフォルトブランチ名を master から main へ変更する

2024/05/12に公開

GitHub のガイドに書いてある。

https://docs.github.com/ja/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch

抜粋すると次の手順となる。

  1. GitHub 上でブランチ名を変更する
    • https://github.com/<your name or organizaion name>/<repository name>/branches
  2. メンバーがそれぞれ、手元のワーキングディレクトリーで次のコマンドを流す
    git branch -m master main
    git fetch origin
    git branch -u origin/main main
    git remote set-head origin -a
    git remote prune origin
    

CLI でリモートブランチ名を変更するには、一度ブランチを消さないといけないようなのでオペレーションミスのリスクも考えて 1 番は GitHub 上でやると良い。

https://stackoverflow.com/a/9525744

GitHubで編集を提案

Discussion