我在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正常工作?


当前回答

The first thing you may want to confirm is the internet connection. Though, internet issues mostly will say that the repo cannot be accessed. Ensure you have set up ssh both locally and on your github. See how Ensure you are using the ssh git remote. If you had cloned the https, just set the url to the ssh url, with this git command git remote set-url origin git@github.com:your-username/your-repo-name.git If you have set up ssh properly but it just stopped working, do the following: eval "$(ssh-agent -s)" ssh-add If you are still having the issue, check to ensure that you have not deleted the ssh from your github. In a case where the ssh has been deleted from github, you can add it back. Use pbcopy < ~/.ssh/id_rsa.pub to copy the ssh key and then go to your github ssh setting and add it.

我建议你总是使用ssh。对于我合作过的大多数团队来说,除非使用ssh,否则您无法访问回购(大多数是私有的)。对于初学者来说,这可能看起来很难,但后来你会发现它更容易和更安全。

其他回答

进入你的cmd并运行:git config——global http。sslverify假

奇怪的是,我只收到这个错误在1我的许多回购。

我的问题是在安装了新的GitHub Desktop for Windows之后,以前的旧GitHub for Win将键保存在~/中。Ssh /github_rsa和~/. Ssh /github_rsa。新的GitHub for Win期望它在~/。Ssh /id_rsa,所以解决方案只是重命名现有的私钥和公钥:

~/.ssh/github_rsa -> ~/.ssh/id_rsa
~/.ssh/github_rsa.pub -> ~/.ssh/id_rsa.pub

之后,让我再次访问回购没有问题。

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

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

$ 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 /config文件可以触发此错误。

GitHub的test命令基本上为我打印出了解决方案:

ssh -T git@github.com

/用户/ myUser /。第13行:错误的配置选项:something-that-did-not-make-sense

您可以按照以下步骤-

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