我试图设置git与http://danielmiessler.com/study/git/#website来管理我的网站。

我已经到了指令的最后一步:git push website +master:refs/heads/master

我正在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.

这里的一个问题可能是程序正在寻找bill@* **.com。当我通过ssh连接到我的网站,我有一个不同的用户名(让我们说'abc')。也许这个应该是abc@***。com。如果是这样,我不知道如何改变这一点,或者如果我可以推下一个别名


当前回答

I would recommend to check all remotes you have configured with git remote -v If you had your repo configured to a remote that was deleted you will receive this error message: fatal: Could not read from remote repository. Please make sure you have the correct access rightsand the repository exists. Even when trying to push or pull to an other (existing) remote. So if you have a remote that was deleted, you can remove with git remote remove name-of-remote-to-remove and after that you can push or pull to your existing remotes without problems.

其他回答

另一个解决方案:

有时这种情况发生在我身上是因为网络问题。我不完全理解根本问题,但是切换到不同的子网络或使用VPN可以解决这个问题

您可以指定SSH应该发送到远程系统的用户名作为远程URL的一部分。在远程主机名之前输入用户名,后面加@。

git remote set-url website abc@***.com:path/to/repo

如果您仍然得到相同的错误,请确保在git设置->ssh选项卡->ssh client to use设置为openSSH

在Windows 11上使用这些命令解决了我的问题

1. 我打开Git Bash命令并启动ssh-agent。

eval "$(ssh-agent -s)" // this command only work in git bash.

2. 由ssh-key添加

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"  //it must be 4096
ssh-add id_rsa

3.检查是否正确添加。

ssh-add -l

4. 在GitHub上上传其公钥为(授权密钥)

cat id_rsa.pub | clip

5. 取消设置任何代理和GIT_SSH变量

unset GIT_SSH
git config --global --unset http.proxy
git config --global --unset https.proxy

6. 必须检查github.com应该解决。

ping github.com

7. 现在检查Github的连接性。

ssh -T git@github.com

输出

主机“github.com(20.207.73.82)”的真实性不可能是 建立。ED25519密钥指纹为 SHA256: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx该密钥是未知的 您确定要继续连接吗 (是的/不/(指纹))?警告:永久添加'github.com' (ED25519)到已知主机列表。嗨MHamzaRajput !你已经 成功验证,但GitHub不提供shell访问。

实际上,我尝试了很多方法让它在Win7上工作,因为将SSH exectun从本机更改为build-it和向后更改,同样的错误。 偶然,我在“。”中将其更改为HTTPS。Git /config"文件如下:

[remote "origin"]
        url = https://github.com/user_name/repository_name.git
        fetch = +refs/heads/*:refs/remotes/origin/*

最终成功了。所以也许对你也有用。