4
1

More than 3 years have passed since last update.

Githubからのgit cloneでパスワードが聞かれず失敗する(Windows 10)

Last updated at Posted at 2020-03-10

問題点

Github上の自分のプライベートリポジトリからgit cloneする際に、

$ git clone https://github.com/user_name/repos_name.git
Cloning into 'repos_name'...
remote: Repository not found.
fatal: repository 'https://github.com/user_name/repos_name.git/' not found

あるいは

$ git clone https://user_name@github.com/user_name/repos_name.git
Cloning into 'repos_name'...
remote: Repository not found.
fatal: repository 'https://github.com/user_name/repos_name.git/' not found

のようにパスワード入力を求められずに失敗する。

環境

OS:Windows 10
Git Bash: ver 2.25.1

解決策 1

git clone https://user_name:password@github.com/user_name/repos_name.git

の様な形でGithubのユーザー名とパスワードをURLに含める。
しかし、これだとパスワードが********のように伏字にならず、丸見えになってしまう。

解決策 2

先ほどの:passwordを消して

git clone https://user_name@github.com/user_name/repos_name.git

とすることで、パスワード入力を求められる、、、らしいが、私の環境ではこれも同様の出力で失敗した。

解決策 3

試しにpasswordを未入力にして

git clone https://user_name:@github.com/user_name/repos_name.git

とした。すると、

$ git clone https://user_name:@github.com/user_name/repos_name.git
Cloning into 'repos_name'...
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/user_name/repos_name.git/'

と出て認証失敗。
しかし、続けて

git clone https://user_name@github.com/user_name/repos_name.git

を叩くと、今度は無事パスワードを要求された。
その後のcloneはuser_nameもpasswordも要らず、

git clone https://github.com/user_name/repos_name.git

でダウンロードが始まった。
gitわからん_(:3」[_]

追記

コメントより、Windows資格情報マネージャー
コントロール パネル>ユーザーアカウント>資格情報マネージャー
から資格情報 git:https://github.com の編集、削除によってこの問題に対応できることを教えていただきました。

また、

$ git clone https://user_name:@github.com/user_name/repos_name.git

によって資格情報の削除が起こっていたことを確認済みです。
 削除後にGithubアカウントにログインすると新たに資格情報が登録されます。ユーザー名やパスワードの変更を行わない限り、今後はその情報を使って自動的に認証が行われるため、git clone 時のユーザー名やパスワードの入力は不要になります。

4
1
2

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
4
1