LoginSignup
4
2

More than 3 years have passed since last update.

git push origin masterができない!master → mainに変更

Last updated at Posted at 2021-03-10

はじめに

GitとGitHubを用いて、ファイルのバージョン管理(変更の管理)をしようとした時の話。

状況

ファイルの内容を変更し、ターミナルにて、git add .git commitの順に入力し、いざ、リモートリポジトリにpushしようとgit push origin masterコマンドを実行しようとしたら、以下のようなエラーが出ました。

ターミナル
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/Gitユーザー名/ファイル名.git'

原因と解決

試しにブランチ名を確認するため、git branchコマンド実行すると、*mainと表示がされました。
あれ、*masterじゃないの?と思い、調べてみると、

GitHub、これから作成するリポジトリのデフォルトブランチ名が「main」に。「master」から「main」へ変更

という記事を見つけました。以下参照。
https://www.publickey1.jp/blog/20/githubmainmastermain.html

ですので、ターミナルにて、git push origin masterではなく、git push origin mainと入力すると、無事リモートリポジトリにpushすることができました!

4
2
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
4
2