我在Windows上使用TortoiseGit。当我试图从标准Windows资源管理器的上下文菜单克隆时,我得到这个错误:

请确保您拥有正确的访问权限并且存储库存在

更准确地说,终端的快照如下:

——progress -v "git@arobotdev:\git\AlfaRobot. exe。git”“C: \ \ AlfaRobot” 克隆到“C:\Work\AlfaRobot”… 权限被拒绝,请重试。 权限被拒绝,请重试。 权限被拒绝(公钥,密码)。 无法从远程存储库读取。 请确保您拥有正确的访问权限 并且存储库存在。 Git没有干净地退出(退出代码128)(21450 ms @ 19.09.2014 10:36:58)

我应该怎么做才能使git正常工作?


当前回答

这个问题可能与您的ssh-agent有关,您的ssh密钥没有与ssh-agent一起添加。您必须在您的终端上执行以下步骤:-

$ eval "$(ssh-agent -s)" Agent pid 5867 $ ssh-add <private-ssh-key-file-name> // eg。Id_rsa(不是.pub) 为/home/you/输入密码。ssh / id_rsa: [] 标识添加:/home/you/。ssh / id_rsa (/ home /你/ . ssh / id_rsa)

其他回答

您可以按照以下步骤-

Check for existing keys- a. ls -al ~/.ssh Create key if does not exist- Paste the text below, substituting in your GitHub email address. a. ssh-keygen -t ed25519 -C "your_email@example.com" b. When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location. c. At the prompt, type a secure passphrase. Adding your SSH key to the ssh-agent- Fire up the SSH agent and add the key eval ssh-agent -s ssh-add ~/.ssh/id_ed25519 Adding key to Git account- Pull up the key and add to Github account cat ~/.ssh/id_ed25519.pub Navigate to Git account and add SSH key

Github现在使用url方案

Git远程set-url origin https://github.com/username/repository.git

如果您使用的是共享机器,那么使用自己的密码或无密码私钥可能会有些过分。更安全的选项是访问令牌:

进入设置,开发人员设置,个人访问令牌 生成新的令牌。 注意标记的用途。 授予回购权限。 克隆回购:

$ git clone https://<token>@github.com/<user>/<repo>.git

如果你已经克隆了repo,你可以修改你的远程设置:

$ git remote set-url origin https://<token>@github.com/<user>/<repo>.git
$ git pull
Already up to date.

对我来说,这是因为机器上没有SSH密钥。本地检查SSH密钥:

$ cat ~/.ssh/id_rsa.pub

这是您的SSH密钥。将其添加到存储库中的SSH密钥中。 在gitlab转到

配置文件设置-> SSH密钥

然后添加键

我有这个问题,我发现我的系统是错误的dns地址。验证您的网络和测试

ssh -vvv git@bitbucket.org

并读取输出消息。如果你看到“你可以使用git或hg连接到Bitbucket。”一切都很好。