[英]Unable to clone private repository github : Authentication failed
I have created a private repo in github and when I am trying to clone it using cmd (git), I am prompted with github window where I enter my username and password.我在 github 中创建了一个私有存储库,当我尝试使用 cmd (git) 克隆它时,系统会提示我输入用户名和密码 github window。 It says login failed in the cmd and then asks username/password in the cmd. I enter the credentials again and press enter.它说在 cmd 中登录失败,然后在 cmd 中询问用户名/密码。我再次输入凭据并按回车键。 I get error like fatal: Authentication failed for我收到致命错误:身份验证失败
I performed the above operation using https. when I tried with ssh, i get this error git@github.com: Permission denied (publickey).我使用 https 执行了上述操作。当我尝试使用 ssh 时,我收到此错误git@github.com: Permission denied (publickey)。 fatal: Could not read from remote repository.致命:无法从远程存储库读取。 Please make sure you have the correct access rights and the repository exists.请确保您拥有正确的访问权限并且存储库存在。
How can I clone this private repository?我如何克隆这个私有存储库?
Github no longer supports basic account credentials (username and password). Github 不再支持基本帐户凭据(用户名和密码)。 You have to generate a personal access token to proceed.您必须生成个人访问令牌才能继续。 follow these steps here: Generate Personal Access Token在此处执行以下步骤: 生成个人访问令牌
I use Webstorm IDE and it made this very easy to fix.我使用 Webstorm IDE,它很容易解决这个问题。 I hope this works for you.我希望这对你有用。
You can clone a private repository with this syntax of the command below:您可以使用以下命令的语法克隆私有存储库:
* token is personal access token . *令牌是个人访问令牌。
git clone https://<username>:<token>@github.com/<username>/<reponame>.git
To clone a private repository, you need to generate a token(personal access token) and add it to the command.要克隆私有仓库,您需要生成一个令牌(个人访问令牌)并将其添加到命令中。
1, Go to "Settings" : 1、进入“设置” :
2, Scroll down then go to "Developer settings" : 2,向下滚动然后转到“开发人员设置” :
3, Press "Personal access tokens" then press "Generate new token" : 3、按“个人访问令牌”然后按“生成新令牌” :
4, Fill "Note" then check "repo" : 4、填写“Note”然后勾选“repo” :
* If "repo" is not checked, you cannot clone a private repository. *如果未选中“repo” ,则无法克隆私有存储库。
5, Scroll down then press "Generate token" : 5、向下滚动然后按“生成令牌” :
6, Finally, a token(Personal access token) is generated: 6、最后生成一个token(Personal access token) :
This is the command with the token generated above :这是带有上面生成的令牌的命令:
git clone https://<username>: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@github.com/<username>/<reponame>.git
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.