LoginSignup
0
0

More than 1 year has passed since last update.

githubにプロジェクトをアップロードする時にでたエラー error: src refspec master does not match any

Posted at

remote add origin https://github.com/ユーザー名/ディポジトリ名.git
git push -u origin master
を入力すると

error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/ユーザー名/ディポジトリ名.git'

参考にしたサイトが古く
git push -u origin master
ではなく
git push -u origin main
でエラーは突破

以前から利用していたディポジトリはmasterのままで良いらしい

しかしmaindeプッシュしようとするとgithubのユーザーネーム、パスワードの入力を求められるので入力すると今度は

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/・・・
fatal: Authentication failed for 'https://github.com/・・・

とでてきた。
調べてみると現在はパスワードでのアクセスはできず、トークンを使用しなければいけないらしい。

github右上の自分のアイコンをクリックしsettingsを選択
Developer settingsを選択
Personal access tokensの中のtoken (classic)を選択
右上のGenerate new tokenを選びGenerate new token(classic)を選択

Noteにtoken名を入力
Expirationは有効期限なので好きなものを選択。今回は30daysにした。
Scopesの中のrepo、admin:repo_hook、delete_repoにチェックを入れGenerate tokenをクリック

作成されたtokenをコピーする
このtokenはもう表示できないのでどこかに保存する

ターミナルでもう一度
git push -u origin main
を実行するとユーザー名を求められるので入力
パスワードど入力で先ほどコピーしたtokenを入力

無事にプロジェクトフォルダがpushされた!!

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