Git 错误:“请确保您具有正确的访问权限并且存储库存在”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25927914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git error: "Please make sure you have the correct access rights and the repository exists"
提问by Alex
I am using TortoiseGit on Windows. When I am trying to Clone from the context menu of the standard Windows Explorer, I get this error:
我在 Windows 上使用 TortoiseGit。当我尝试从标准 Windows 资源管理器的上下文菜单中克隆时,出现以下错误:
Please make sure you have the correct access rights and the repository exists
请确保您拥有正确的访问权限并且存储库存在
More precisely, the snapshot of terminal is the following:
更准确地说,终端的快照如下:
git.exe clone --progress -v "git@arobotdev:\git\AlfaRobot.git" "C:\Work\AlfaRobot"
Cloning into 'C:\Work\AlfaRobot'...
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
git did not exit cleanly (exit code 128) (21450 ms @ 19.09.2014 10:36:58)
git.exe clone --progress -v "git@arobotdev:\git\AlfaRobot.git" "C:\Work\AlfaRobot"
Cloning into 'C:\Work\AlfaRobot'...
权限被拒绝,请重试。
权限被拒绝,请重试。
权限被拒绝(公钥、密码)。
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限
并且存储库存在。
git 没有完全退出(退出代码 128)(21450 毫秒 @ 19.09.2014 10:36:58)
What should I do to make git work properly ?
我应该怎么做才能使 git 正常工作?
回答by Vishnu
Your git URL might have changed. Change the URL in the local directory by using the following command
您的 git URL 可能已更改。使用以下命令更改本地目录中的 URL
git remote set-url origin git@yourGitUrlHere
回答by Onkar_M18
That problem might be having with your ssh-agent, your ssh key hasn't been added with ssh-agent.You have to apply following steps using your terminal:-
该问题可能与您的 ssh-agent 相关,您的 ssh 密钥尚未通过 ssh-agent 添加。您必须使用终端应用以下步骤:-
$ eval "$(ssh-agent -s)"
Agent pid 5867
$ ssh-add
Enter passphrase for /home/you/.ssh/id_rsa: [] Identity added: /home/you/.ssh/id_rsa (/home/you/.ssh/id_rsa)
$ eval "$(ssh-agent -s)"
代理pid 5867
$ SSH 添加
输入 /home/you/.ssh/id_rsa 的密码:[] 添加的身份:/home/you/.ssh/id_rsa (/home/you/.ssh/id_rsa)
then it will work..cheers J.
那么它会起作用..干杯J。
回答by Jacek Góraj
For me it was because of no SSH key on the machine. Check the SSH key locally:
对我来说,这是因为机器上没有 SSH 密钥。在本地检查 SSH 密钥:
$ cat ~/.ssh/id_rsa.pub
This is your SSH key. Add it to your SSH keys in the repository.
In gitlab go to
这是您的 SSH 密钥。将其添加到存储库中的 SSH 密钥中。
在 gitlab 中转到
profile settings -> SSH Keys
配置文件设置 -> SSH 密钥
and add the key
并添加密钥
回答by Lovekush Vishwakarma
回答by RyPope
Github now uses a url scheme
Github 现在使用 url 方案
git remote set-url origin https://github.com/username/repository.git
git remote set-url origin https://github.com/username/repository.git
回答by Mudassir Razvi
You are trying to clone the repository over ssh: git@arobotdev...
, and your SSH keys are not properly set on server. There are multiple reasons to this:
您正在尝试通过 ssh: 克隆存储库git@arobotdev...
,并且您的 SSH 密钥未在服务器上正确设置。这有多种原因:
- Your public key might not be saved in authorized_keys file of user git
- If 1 is not true the Your private key is not saved in .ssh/ folder of your HOMEDIR.
- Permissions are not properly set
- 您的公钥可能未保存在用户 git 的 authorized_keys 文件中
- 如果 1 不正确,则您的私钥不会保存在 HOMEDIR 的 .ssh/ 文件夹中。
- 权限设置不正确
If all 3 above are untrue then my only conclusion can be to try:
git@arobotdev:AlfaRobot.git
Assuming AlfaRobot.git is in HOMEDIR of git user and not inside a folder called git which resides in HOMEDIR of user git.
如果以上所有 3 项都不正确,那么我唯一的结论就是尝试:
git@arobotdev:AlfaRobot.git
假设 AlfaRobot.git 位于 git 用户的 HOMEDIR 中,而不是位于用户 git 的 HOMEDIR 中的名为 git 的文件夹中。
回答by parasrish
The rsa.pub (i.e. public key generated), needs to be added on the github>> settings>>ssh keys page. Check that, you have not added this public key in the repository-settings >> deployment keys. If so, remove the entry from here and add to the first place mentioned.
rsa.pub(即生成的公钥),需要在github>>settings>>ssh keys页面添加。检查您是否没有在存储库设置 >> 部署密钥中添加此公钥。如果是这样,请从此处删除条目并添加到提到的第一个位置。
Setup of the pub-private keys in detail.
在酒吧里,私有密钥的设置细节。
It will work hence!
它会因此起作用!
回答by albert
I had this problem, and i discover that my system was with wrong dns address. Verify your network and test with
我遇到了这个问题,我发现我的系统使用了错误的 dns 地址。验证您的网络并测试
ssh -vvv [email protected]
And read the output messages. If you see "You can use git or hg to connect to Bitbucket." , everything is ok.
并阅读输出消息。如果您看到“您可以使用 git 或 hg 连接到 Bitbucket”。, 一切都好。
回答by Obinna Nnenanya
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 [email protected]: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.
您可能要确认的第一件事是互联网连接。尽管如此,互联网问题大多会说无法访问回购。
确保您已在本地和 github 上设置了 ssh。看看如何
确保您使用的是 ssh git 远程。如果您已经克隆了 https,只需使用此 git 命令将 url 设置为 ssh url
git remote set-url origin [email protected]:your-username/your-repo-name.git
如果您已正确设置 ssh 但它刚刚停止工作,请执行以下操作:
eval "$(ssh-agent -s)"
ssh-add
如果问题仍然存在,请检查以确保您没有从 github 中删除 ssh。如果 ssh 已从 github 中删除,您可以将其添加回来。使用
pbcopy < ~/.ssh/id_rsa.pub
复制的SSH密钥,然后去你的github的ssh设置并添加它。
I will recommend you always use ssh. For most teams I've worked with, you can't access the repo (which are mostly private) except you use ssh. For a beginner, it may appear to be harder but later you'll find it quite easier and more secured.
我会建议您始终使用 ssh。对于我合作过的大多数团队,除了使用 ssh 之外,您无法访问 repo(大部分是私有的)。对于初学者来说,它可能看起来更难,但后来你会发现它更容易和更安全。
回答by Paris Qian Sen
Here is how I solve this issue. I was using Babun(mintty.exe) on Win7/10. When I have tried many solutions mentioned above, and none of them works. I realized maybe I just used wrong ssh agent...
So I run echo $GIT_SSH
to find out, it shows the path to Plink.exe
.
What I actually expected is OpenSSH.
这是我解决这个问题的方法。我在 Win7/10 上使用 Babun(mintty.exe)。当我尝试了上面提到的许多解决方案时,它们都不起作用。我意识到我可能只是使用了错误的 ssh 代理......所以我跑去echo $GIT_SSH
寻找,它显示了Plink.exe
. 我真正期望的是 OpenSSH。
So, I add following one-liner to ~/.zshrc
file
所以,我将以下单行添加到~/.zshrc
文件中
Note 1: You can execute it in babun directly also
Note 2: You if you use bash then the config file is.bashrc
注 1:您也可以直接在 babun 中执行它
注 2:如果您使用 bash 那么配置文件是.bashrc
export GIT_SSH=$(which ssh)
And It works!
它有效!