简体   繁体   English

无法从 Git 克隆存储库

[英]Unable to clone repository from Git

I am new to Git.我是 Git 的新手。 I am trying to clone a repository.我正在尝试克隆一个存储库。 I am able to clone it using Git bash command.我可以使用 Git bash 命令克隆它。 But when I try to clone it using STS or Source Tree I get an error saying authentication not supported.但是当我尝试使用 STS 或 Source Tree 克隆它时,我收到一条错误消息,指出不支持身份验证。 I tried the following still nothing worked.我尝试了以下仍然没有任何效果。

  1. Created Personal Access Token with api and read_user access.使用 api 和 read_user 访问创建个人访问令牌。
  2. Tried adding https.sslVerify false尝试添加https.sslVerify false
  3. Generated RSA Key from windows-->preferences-->Network Connection-->SSH2-->KeyManagement and pasted the public key.从 windows-->preferences-->Network Connection-->SSH2-->KeyManagement 生成 RSA 密钥并粘贴公钥。

Please guide me further.请进一步指导我。

Best approach would be to configure using SSH:最好的方法是使用 SSH 进行配置:

  1. Generate the SSH key with ssh-keygen -t rsa -b 4096 (seehere )使用ssh-keygen -t rsa -b 4096生成 SSH 密钥(请参阅此处
  2. Copy the content of your public SSH key, it is the file id_rsa.pub by default.复制您的公共 SSH 密钥的内容,默认情况下它是文件id_rsa.pub

    Location: ~/.ssh (or if you are a window user, it will use whatever $HOME is, ie, $HOME/.ssh )位置: ~/.ssh (或者如果您是窗口用户,它将使用 $HOME 是什么,即$HOME/.ssh

  3. Paste the content into your GitHub/BitBucket account on the SSH key section将内容粘贴到 SSH 密钥部分的 GitHub/BitBucket 帐户中

Get the repo获取回购

Just clone it:只需克隆它:

GitHub: git clone git@github.com:YOUR_USERNAME/REPO_NAME.git GitHub: git clone git@github.com:YOUR_USERNAME/REPO_NAME.git

BitBucket: git clone git@bitbucket.org:USERNAME/REPO_NAME.git BitBucket: git clone git@bitbucket.org:USERNAME/REPO_NAME.git

There are 2 methods you can try using您可以尝试使用 2 种方法

  1. Try cloning by adding your git username on the clone URL通过在克隆 URL 上添加您的 git 用户名来尝试克隆

git clone https://username@github.com/username/repository.git git 克隆https://username@github.com/username/repository.git

It will prompt you for your password.它会提示您输入密码。

Alternatively, you can use或者,您可以使用

git clone https://username:password@github.com/username/repository.git git clone https://username:password@github.com/username/repository.git

  1. Adding an SSH key on GIT generated from your machine.在从您的机器生成的 GIT 上添加 SSH 密钥。 Use the link shared below to generate one https://help.github.com/en/enterprise/2.17/user/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent使用下面共享的链接生成一个https://help.github.com/en/enterprise/2.17/user/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to- ssh-agent

for clone repository, you can use this command in terminal对于克隆存储库,您可以在终端中使用此命令

git clone https://github.your_project_url.com/project git clone https://github.your_project_url.com/project

and when it asks for username and password当它要求输入用户名和密码时

user_name: type Github user_name用户名:输入 Github 用户名

password: don't use Github password which you use at the time of login to Github, instead, you have to use a personal access token密码:不要使用您在登录 Github 时使用的 Github 密码,而必须使用个人访问令牌

to generate this personal access token open your GitHub account and go to "Settings/Developer settings/Personal access tokens"要生成此个人访问令牌,请打开您的 GitHub 帐户并转到“设置/开发人员设置/个人访问令牌”

thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM