我试图设置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。如果是这样,我不知道如何改变这一点,或者如果我可以推下一个别名


当前回答

我在ssh代理中有一个错误的ssh私钥。

先删除所有键

ssh-add -D

然后加了正确的键。

ssh-add ~/.ssh/id_rsa

其他回答

有类似的问题。 我已经通过这条指令(ssh-keygen)生成ssh密钥到我的帐户,或者如果你已经有一个添加它,不生成新的一个。 然后我通过命令shell更改了我的全局凭据,如果你已经克隆了repo,它们也可以在项目根目录中本地更改项目(删除全局标志),但这不是我的情况。 git配置——global user.name“你的姓” Git配置——全局用户。电子邮件“youremail.com”

在极少数情况下,您将得到“致命:无法从远程存储库读取”错误,如在

[user@example.com repo]$ git fetch --all --prune
Fetching origin
exec request failed on channel 0
fatal: Could not read from remote repository.

当Git服务器文件系统已满时。要验证这一点,请运行:

ssh -v ssh://git@yourhost/path/repo.git

如果服务器像这样回复:

...
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/...
SHA256:...
debug1: Server accepts key: /home/...
SHA256:...
Authenticated to linux-git.....com ([xxx.xxx.xx.xx]:xx) using "publickey".
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: filesystem full
...
debug1: Remote: PTY allocation disabled.
PTY allocation request failed on channel 0
shell request failed on channel 0

服务器的磁盘空间会被占满。

我知道这个答案不会得到很多人的支持;为了完整起见,添加它。

附注:也可以使用类似

GIT_SSH_COMMAND="ssh -v" git pull

诊断问题。

对于那些有此问题的私人远程回购。确保你在远程服务器上接受了Xcode协议:我们花了几周时间才找到这个解决方案

从命令行使用这个命令:sudo xcodebuild -license

user@server:/etc/nginx$ cat .git/config 
...
[remote "origin"]
    url = git@gitlab.com:user/.git
    fetch = +refs/heads/*:refs/remotes/origin/*
...

使用ssh代替https。 在git中使用ssh密钥(添加ssh密钥)。 如果您是root用户,请使用ssh密钥。


$ sudo ssh-keygen
$ cat /root/.ssh/id_rsa.pub 

$ git init
$ git add file
$ git commit -m "add first file"
$ git remote add origin git@gitlab.com:user/example.git 
$ git push -u origin master

我遇到这个问题是由于多次输入错误的密码。

所以我必须将MaxAuthTries更改为更大的数字:

在服务器端打开sshd_config:

vim  /etc/ssh/sshd_config

更改MaxAuthTries编号:

MaxAuthTries 100    # there I change to 100, you can change to a bigger than your current tries number