MENU

Githubの初回pushでエラー(error: src refspec main does not match any error: failed to push some refs to ‘github.com:*/*.git’)が出た時の対処法

Githubで新しいプロジェクトを作成して、存在するレポジトリを初めてpushするとき

…or push an existing repository from the command line
git remote add origin git@github.com:{ユーザ名}/{リポジトリ名}.git
git branch -M main
git push -u origin main

上記のように案内されるので、ついついそのまま実行しがちですが、そうするとエラーが出ます。

$ git push -u origin main
error: src refspec main does not main any
error: failed to push some refs to 'github.com:{ユーザ名}/{リポジトリ名}.git'

Addし忘れているからですね。なので、ちゃんとAddしてから実行します。

$ git add .
$ git push -u origin main

これでOK

よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次