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】error: src refspec main does not match anyの対処法

Last updated at Posted at 2025-02-26

症状

新しいリポジトリを作成し、ローカルのフォルダをpushしようとしたら、下記のエラーが発生しました
error
git init
Initialized empty Git repository in hoge/.git/

git commit -m "first commit"
On branch master

Initial commit

nothing to commit (create/copy files and use "git add" to track)

git branch -M main

git remote add origin https://github.com/TKWebSE/BookOfAtCoderBeginning.git

git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/hoge.git'

解決策

フォルダの中身が空っぽで、ファイルがなかったたので、ファイルを作って再度addとcommitしたら、pushできました
空ファイルさくせ
git add -A

git commit -m "hoge"

git push -u origin main

参考

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?