0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Git masterブランチの名称をmainに変える

Last updated at Posted at 2024-06-02

概要

Gitにてmasterブランチの名称をmainに変える方法を簡単にまとめる。

方法

  1. ローカルリポジトリにて下記を実行し、ブランチ名をmainに切り替える(未pushの場合はこの手順だけで完了となる。masterブランチをリモートリポジトリにpush済みの方はこのあとも継続して作業する必要がある。)

    git switch master
    git branch -m master main
    
  2. 下記を実行してリモートリポジトリにpushする

    git push -u origin main
    
  3. リモートリポジトリのサービス(Githubなど)のリポジトリの画面を開く(筆者はGithubユーザーなのでGithubの場合を説明する。)

  4. 「Settings」を開く

    CleanShot 2024-06-02 at 15.21.35@2x.png

  5. サイドバーの「General」をクリックし「Default branch」の「相互矢印マーク」をクリックする。

    CleanShot 2024-06-02 at 15.25.00@2x.png

  6. 「master」と表示されているプルダウンをクリックし、「main」をクリックする。

    CleanShot 2024-06-02 at 15.25.43@2x.png

  7. 変更できたら「Update」をクリックする。

    CleanShot 2024-06-02 at 15.26.33@2x.png

  8. リスクを理解しているか聞かれるので承諾できるなら赤文字のボタンをクリックする。

    CleanShot 2024-06-02 at 15.27.17@2x.png

  9. Defailt branchがmainに変わった。

    CleanShot 2024-06-02 at 15.28.03@2x.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?