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


当前回答

我犯了一个很常见的错误。我使用剪辑命令xclip -sel剪辑< ~/.ssh/id_rsa复制。但是在粘贴到github键输入框期间,我使用退格删除了最后换行符,这实际上改变了公钥。

所以,总是复制和粘贴ssh公钥,因为它是没有删除最后换行。

其他回答

我在上传项目到gitlab时遇到了这个错误。我没有从git克隆,而是上传项目。要将代码推送到gitlab,有两种方法:使用ssh或https。如果你使用https,你必须输入用户名和密码的gitlab帐户。为了推动你的代码到git,你可以使用下面的一个。

第一次推到Git

>$ cd
>$ mkdir .ssh;cd .ssh
>$ ssh-keygen -o -t rsa -b 4096 -C "email@example.com"

-C参数是可选的,它在键的末尾提供了一个注释,如果您有多个键,则可以将其与其他键区分开来。 这将创建id_rsa(您的私钥)和id_rsa。Pub(您的公钥)。我们传递我们的公钥,并保留我们的私钥——嗯,是私有的。在Gitlab的用户设置中,您可以将您的公钥添加到您的帐户,从而允许我们最终推送。

在项目位置(目录)中使用以下命令

git init

它将当前目录转换为Git存储库。这将在当前目录中添加一个.git子目录,并使开始记录项目的修订成为可能。

使用https路径推送

git push --set-upstream https://gitlab.com/Account_User_Name/Your_Project_Name.git master

使用ssh路径

git push --set-upstream git@gitlab.com:Account_User_Name/Your_project_Name.git master

—set-upstream:告诉git到原点的路径。如果Git之前推送过当前的分支,它会记住原点在哪里

master:这是初始化时我想推到的分支的名称

将这些行添加到你的.get/config文件中(感谢@kovshenin回答Git Pull: Change Authentication):

[credential]
    helper = wincred

您可以按照以下步骤-

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

类似的问题:

我给密码时,git克隆使用SSH URL的git。 所以这个错误现在显示,每次我打开VS Code在Windows 10

下面修复了这个问题:

1。在CMD下执行以下命令

setx SSH_ASKPASS "C:\Program Files\Git\mingw64\libexec\git-core\git-gui--askpass"
setx DISPLAY needs-to-be-defined

2。退出CMD & VS Code

3.重新打开VS Code

4所示。VS Code现在显示一个弹出对话框,我们可以输入passspharse

以上命令适用于Windows操作系统,类似的指令也适用于Linux/MAC。

如果它之前工作,突然停止工作:

此问题可能是因为有时ssh-agent在重新启动时不是持久的。你应该检查ssh-agent是否添加了你的密钥:

ssh-add -l -E md5

如果你得到如下输出:

The agent has no identities.

这意味着ssh-agent丢失了您的密钥。在这种情况下,您只需要再次添加标识键。喜欢的东西:

ssh-add ~/.ssh/git_rsa

错误现在应该消失了!