git:致命:无法从远程存储库读取
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13509293/
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: fatal: Could not read from remote repository
提问by user61629
I am trying to set git up with http://danielmiessler.com/study/git/#websiteto manage my site.
我正在尝试使用http://danielmiessler.com/study/git/#website设置 git来管理我的网站。
I have gotten to the last step in the instructions: git push website +master:refs/heads/master
我已经到了说明的最后一步:git push website +master:refs/heads/master
I am working using the git ming32 command line in win7
我在 win7 中使用 git ming32 命令行
$ git push website +master:refs/heads/master
Bill@***.com's password:
Connection closed by 198.91.80.3
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
One problem here may be that the program is looking for Bill@***.com. when I connect via ssh to my site I have a different username( lets say 'abc'). so maybe this should be abc@***.com. If so I don't know how to change this or if I can push under an alias
这里的一个问题可能是该程序正在寻找 Bill@***.com。当我通过 ssh 连接到我的网站时,我有一个不同的用户名(比如“abc”)。所以也许这应该是 abc@***.com。如果是这样,我不知道如何更改它,或者我是否可以使用别名
采纳答案by rob mayoff
You can specify the username that SSH should send to the remote system as part of your remote's URL. Put the username, followed by an @
, before the remote hostname.
您可以指定 SSH 应该发送到远程系统的用户名作为远程 URL 的一部分。将用户名后跟@
, 放在远程主机名之前。
git remote set-url website abc@***.com:path/to/repo
回答by Johnny Cage
Your ssh key most likely had been removed from ssh agent
您的 ssh 密钥很可能已从 ssh 代理中删除
ssh-add ~/.ssh/id_rsa
where id_rsa is a ssh key associated with git repo
其中 id_rsa 是与 git repo 关联的 ssh 密钥
回答by Tombart
Make sure you have correct url in .git/config
确保你有正确的网址 .git/config
url = [email protected]:username/repo.git
If it's your first push, you'll need to set up correct upstream
如果这是您的第一次推送,则需要设置正确的上游
$ git push -u origin master
You can check which key is used by:
您可以通过以下方式检查使用哪个键:
$ ssh -vvv [email protected]
The reply should contain something like this:
回复应包含如下内容:
debug1: Next authentication method: publickey
debug1: Offering RSA public key: ~/.ssh/id_rsa
...
You've successfully authenticated, but GitHub does not provide shell access.
Also it's possible to define rules for ssh in ~/.ssh/config
, e.g. based on aliases:
也可以为 ssh in 定义规则~/.ssh/config
,例如基于别名:
Host github
HostName github.com
User git
IdentityFile "~/.ssh/id_rsa"
Host git
HostName github.com
User git
IdentityFile "~/.ssh/some_other_id"
You can set connect to different ports, use different username etc. for each alias.
您可以为每个别名设置连接到不同的端口,使用不同的用户名等。
回答by Manish Nakar
I was facing same issue a while ago...
我前一段时间也面临同样的问题......
my .git/config had
我的 .git/config 有
url = [email protected]:manishnakar/polymer-demo.git
I replaced it with
我用
url = https://github.com/manishnakar/polymer-demo.git
and it works now:)
现在可以使用了:)
回答by Scott Lindner
Try removing the GIT_SSH environment variable with unset GIT_SSH
. This was the cause of my problem.
尝试删除 GIT_SSH 环境变量unset GIT_SSH
。这是我的问题的原因。
回答by user3362907
Make sure ssh-agent is running by executing the following command on your terminal:
通过在终端上执行以下命令确保 ssh-agent 正在运行:
eval $(ssh-agent -s)
Source: Github documentation
来源:Github 文档
回答by Bastin Robin
This is usually caused due to the SSH key is not matching with the remote.
这通常是由于 SSH 密钥与远程不匹配造成的。
Solutions:
解决方案:
Go to terminal and type the following command (Mac, Linux) replace with your email id.
ssh-keygen -t rsa -C "[email protected]"
Copy the generated key using following command starting from word ssh.
cat ~/.ssh/id_rsa.pub
- Paste it in github, bitbucket or gitlab respective of your remote.
- Save it.
转到终端并键入以下命令(Mac、Linux)替换为您的电子邮件 ID。
ssh-keygen -t rsa -C "[email protected]"
使用以下命令从 word ssh 开始复制生成的密钥。
cat ~/.ssh/id_rsa.pub
- 将其粘贴到您遥控器的 github、bitbucket 或 gitlab 中。
- 保存。
回答by Pratik Patel
I had the same problem.
我有同样的问题。
This error means that you have not specified your remote URL location upon which your code will push.
此错误意味着您尚未指定您的代码将推送到的远程 URL 位置。
You can set remote URL by 2 (mainly) ways:
您可以通过两种(主要)方式设置远程 URL:
Specify remote URL via executing command on Git Bash.
Navigate to your project directory
Open Git Bash
Execute command:
git remote set-url origin <https://abc.xyz/USERNAME/REPOSITORY.git>
Mention remote URL direct in config file
Navigate to your project directory
Move to .gitfolder
Open configfile in text editor
Copy and paste below lines
[remote "origin"] url = https://abc.xyz/USERNAME/REPOSITORY.git fetch = +refs/heads/*:refs/remotes/origin/*
通过在 Git Bash 上执行命令指定远程 URL。
导航到您的项目目录
打开 Git Bash
执行命令:
git remote set-url origin <https://abc.xyz/USERNAME/REPOSITORY.git>
直接在配置文件中提及远程 URL
导航到您的项目目录
移动到.git文件夹
在文本编辑器中打开配置文件
复制并粘贴到下面几行
[remote "origin"] url = https://abc.xyz/USERNAME/REPOSITORY.git fetch = +refs/heads/*:refs/remotes/origin/*
For more detailed info visit this link.
有关更多详细信息,请访问此链接。
回答by Mohammed Nasiruddin
After doing some research I've finally got solution for this, you have declared a environment variable to plink.exe path. So if you remove that path, reopen the git bash and try cloning through SSH it will work.
在做了一些研究之后,我终于找到了解决方案,您已经为 plink.exe 路径声明了一个环境变量。因此,如果您删除该路径,请重新打开 git bash 并尝试通过 SSH 进行克隆,它将起作用。
Refer to this link
参考这个链接
回答by tan75
I had the same error.
The solution was following:
I've corrected my url in .git/config
.
Just copied that from HTTPS clone URL. That would be something like that:
我有同样的错误。解决方案如下:我在.git/config
. 刚刚从 HTTPS 克隆 URL 复制了它。那将是这样的:
url = https://github.com/*your*git*name*/*your*git*app*.git
It worked.
有效。