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


当前回答

在我的情况下,我试图克隆与sudo。根据Github的文档,你不应该使用sudo与git克隆: https://help.github.com/en/github/authenticating-to-github/error-permission-denied-publickey#should-the-sudo-command-be-used-with-git

我所做的是给当前用户编辑目录的权限(Debian 9):

chown myuser:root .

然后克隆没有sudo,它工作。

其他回答

对我来说非常简单的解决方案,见下面:-

问题

$ git clone git@github.com:xxxxx/xxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

这也会超时

$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out

这可能有用

$ ssh -T -p 443 git@ssh.github.com
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.

覆盖SSH设置

$ vim ~/.ssh/config

# You can also manually open the file and copy/paste the section below
# Add section below to it
Host github.com
  Hostname ssh.github.com
  Port 443

然后再试一次

$ ssh -T git@github.com
Hi xxxxx! You've successfully authenticated, but GitHub does not
provide shell access.

现在试试克隆(应该有用)

$ git clone git@github.com:xxxxxx/xxxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 15 (delta 0), reused 15 (delta 0), pack-reused 0
Receiving objects: 100% (15/15), 22.90 KiB | 4.58 MiB/s, done.

参考:here =>使用端口443的HTTPS

我也犯了同样的错误,这让我得到了这个没有帮助的答案。 我试图创建一个新的“裸”存储库,第一次使用以下命令跟踪到NTFS位置:

cd myrepository
git init --bare \\myserver.mycompany.local\myrepository.git
git init
git status
git add .
git status
git commit -m "Initial Commit"
git remote add origin \\myserver.mycompany.local\myrepository.git
git push -u origin master
git status

我的问题原来是在NTFS位置中使用后斜杠而不是前斜杠,当试图添加原点来设置(新的)跟踪上游分支时。

我必须删除原点使用:

git remote rm origin

然后使用预期的正斜杠再次添加原点

git remote add origin //myserver.mycompany.local/myrepository.git

希望这对将来的人有所帮助。

确保你在.git/config中有正确的url

url = git@github.com:username/repo.git

如果这是你第一次推,你需要在正确的上游设置

$ git push -u origin master

你可以检查哪个键被使用:

$ ssh -vvv git@github.com

回复应该包含如下内容:

debug1: Next authentication method: publickey
debug1: Offering RSA public key: ~/.ssh/id_rsa
...
You've successfully authenticated, but GitHub does not provide shell access.

也可以在~/中为ssh定义规则。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"

您可以为每个别名设置连接到不同的端口,使用不同的用户名等。

在我的情况下,它是postBuffer..

git config --global http.postBuffer 524288000

参考阅读:https://gist.github.com/marcusoftnet/1177936

当我试图将代码从工作默认点推到工作git时,我得到了这个错误。 所以我采取了以下步骤:

去我的个人git账户,用默认设置创建了repo 在终端上,git远程添加origin git@github.com:/.git Git push——set-upstream origin master,确保origin是upstream,下一次提交只能使用Git push进行。

出于某种原因,没有其他方法适合我。希望这有助于使用2个或更多git帐户的人。