LoginSignup
0
0

More than 1 year has passed since last update.

GitHubにpushできない Username for 'https://github.com': って訊かれる!

Last updated at Posted at 2022-10-17

とりいそぎ、GitHubで問題が生じたため、投稿します。 情報を希望します。
状況を改善したので、追記します。

経過

GitHubの練習のため以下を行ったが、リモートリポジトリにpushできない。

cd 
mkdir gitFolder
git init
git config --global user.name "YohYasushi"
git config --global user.email "(めるあど)@gmail.com"

を行った。

gitFolderというフォルダを作成して、ここに、git initしたあと、configをいじっている流れですね。

git config --listでは、

user.name=YohYasushi
user.email=(めるあど)@gmail.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/YohYasushi/Renshu.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.main.remote=origin
branch.main.merge=refs/heads/main

となりました。ってかこの段階で詳細なパラメーターは見てません。

(なお、GitHub上で、リポジトリRenshuは先に作ってあります。README.md は作らせないのが大事っすね。)

次に、SSH Keyを作成する。

ssh-keygen -C "(めるあど)@gmail.com"

っすね。passphrase(ヒミツ)も入力し、

cat ~/.ssh/id_rsa.pub

で公開鍵を確認し、WebでGitHubのSettingにいって、SSH Keysにコピペして登録する(ここは既知なんで端折ります)。
最後に、

ssh -T git@github.com

を行って、

Are you sure you want to continue connecting (yes/no/[fingerprint])?

をyesにし、該当するGmailのパスワードも入力し、

Hi YohYasushi! You've successfully authenticated, but GitHub does not provide shell access.

を得た。SSH認証がOKとなった。
やれやれと思い、

cd
cd gitFolder/
git clone https://github.com/YohYasushi/Renshu.git
cd Renshu/
touch t1.txt
code t1.txt

で、aiueoとかなんでもいいから入れてから、

git add .
git commit -m "1st" 
git push -u origin main 

をしたら、ここが肝心なんですが、

Username for 'https://github.com': //ここでYohYasushiを入力し、
Password for 'https://YohYasushi@github.com': //パスワードを入力しても、

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/YohYasushi/Renshu.git/'

いやいや、HTTPなんか使ってねぇし!

ネットでも情報が少なく、悩んでいる。鋭意、検索中。

きっとショボいところで躓いていると思っている。

改善したので、追記します。
理由は再掲しますが、↓にあります。

remote.origin.url=https://github.com/YohYasushi/Renshu.git

思いっきり、https://github.com/YohYasushi/Renshu.git って書いてある!これを修正しましょう。

下記のコマンドで、当該フォルダに移動し、

cd
cd gitFolder/Renshu/
ls -al

とすると、↓が表示されます。

合計 16
drwxrwxr-x 3 yohyasushi yohyasushi 4096 10月 17 22:33 .
drwxrwxr-x 4 yohyasushi yohyasushi 4096 10月 17 22:30 ..
drwxrwxr-x 8 yohyasushi yohyasushi 4096 10月 17 22:34 .git
-rw-rw-r-- 1 yohyasushi yohyasushi    5 10月 17 22:33 text1

次に、

cd .git/
ls

で、

COMMIT_EDITMSG  HEAD  branches  config  description  hooks  index  info  logs  objects  refs

とした中にある、configを修正しないといけません。

code config

とした中身は、

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = https://github.com/YohYasushi/Renshu.git  //この行が問題。
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
	remote = origin
	merge = refs/heads/main

上記を、

[remote "origin"]
	url = git@github.com:YohYasushi/Renshu.git 

と、修正したら完了です。駆け足ですが、対応を書きました。

参考文献など

Git入門コマンドライン演習80

GitHub実践入門

ネットの上の皆さん!ありがとう!(詳細はツイート参照)

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