まずリポジトリを置くディレクトリを作成。mkdir 〇〇

その後は以下のコマンドを順番に打つ。

echo "# a" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin <https://github.com/〇〇/a.git>
git push -u origin main

途中でusernameとpasswordを質問された際に詰まった。

具体的にいうと

git push しようとした時に以下の様にusernameとpasswordを質問された。

Username for '[<https://github.com>](<https://github.com/>)': 
Password for '[<https://〇〇@github.com>](<https://[email protected]/>)':

usernameとpasswordがわからず以下のような認証エラーが出た。

fatal: Authentication failed for '<https://github.com/iwaki-toshiyuki/PHP-practice.git/>'

途中トークンなどを作ろうとしたがうまくいかなかった。

どう対処したか?

HTTPS URLからSSH URLに変更する

SSH鍵を使用して認証する場合、HTTPS URLではなくSSH URLを使用したらうまくいった。