Git push给出Permission denied(publickey)。致命:远程端意外挂断。我该怎么办?

时间:2012-12-28 04:17:31

标签: git

所以我今天在终端打开我的rails项目并进行一些更改并尝试推送到github,但它不起作用。我搜索谷歌和堆栈溢出,所有人都指出安装github的说明来解决我的问题。

所以我完成了所有说明,但仍然遇到了同样的问题。请帮助!

admin@new-host-2:~/Desktop/sample_app$ git status
# On branch filling-in-layout
# Your branch is ahead of 'origin/filling-in-layout' by 3 commits.
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   app/views/pages/home.html.erb
#
no changes added to commit (use "git add" and/or "git commit -a")

admin@new-host-2:~/Desktop/sample_app$ git add .
admin@new-host-2:~/Desktop/sample_app$ git commit -am 'testing git yet again'
[filling-in-layout b607a16] testing git yet again
 1 files changed, 1 insertions(+), 1 deletions(-)
admin@new-host-2:~/Desktop/sample_app$ git push
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

admin@new-host-2:~/Desktop/sample_app$ ssh-add -l
The agent has no identities.

admin@new-host-2:~/Desktop/sample_app$ git credential-osxkeychain
Usage: git credential-osxkeychain <get|store|erase>

为什么它会说#你的分支在3次提交之前超过'origin / filling-in-layout'?

1 个答案:

答案 0 :(得分:3)

我建议这说明原因

admin@new-host-2:~/Desktop/sample_app$ ssh-add -l
The agent has no identities.

您需要使用您的密钥添加到ssh-agent   ssh-add / path to keyfile

如果您有密码,系统会要求您输入密码,然后密钥将添加到您的密钥链中。然后,您应该能够提交提交。

它之所以说“#你的分支超过了3个提交的'origin / filling-in-layout'”是因为你尚未提交你的提交。您的本地版本是远程版本之前的3次提交。一个你成功完成推动,情况并非如此。