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?

More than 1 year has passed since last update.

git push -u origin mainがうまくいかない時

Posted at

git push -u origin maiがうまくいかない

現在progate pathをやっているのですが、その課題で、プッシュがうまくいかず、
error: src refspec main does not match anyというメッセージが出ました。
結論から言うとmainではなくmasterにしたらうまく行ったのですが、それを調べていたら、Qiitaの記事で、解説されている方がいたので、参考に記載します。

調べた方法としては、

  1. そのままエラーメッセージをググって、出てきたqiita記事の内容から、git branchを実行すればいいことがわかったので、
  2. git branch実行すると* masterと出てきたので、mainではなくmasterなのだとわかり
  3. git push -u origin masterを実行したら、うまく行ったと言う感じです。

参考になれば嬉しいです。

参考の記事にも記載されていますが、masterとmainを関連付けすると良いそうです。

progate pathで質問して返ってきた回答も載せておきます。

現在のGitでは、既定のブランチ名がmasterからmainに変更されています。したがって、あなたのリポジトリでmasterを使っている場合、git branchで表示されるブランチ名が* masterになります。
mainとmasterの違いはブランチ名だけです。どちらもデフォルトブランチとして機能します。最近のGitバージョンではmainがデフォルトで作成されますが、古いバージョンではmasterが使われていました。どちらのブランチ名でも問題ありません。
リモートリポジトリにプッシュする際に関連付けを行うことで、今後同じブランチへのプッシュが簡単になります。-u(--set-upstream)オプションを使用することで、ローカルブランチとリモートブランチが関連付けられ、今後git pushやgit pullを実行する際にブランチ名を指定する必要がなくなります。

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?