无法在pygit2中进行ssh推送

时间:2014-07-03 17:03:08

标签: git ssh libgit2 pygit2

我正在尝试使用pygit2将ssh推送到github repo。 这是我不断得到的错误 你能指出错误吗?

>>> sshcred = repo_.pygit2.credentials.Keypair('avckp','id_rsa.pub','id_rsa','')
>>> remo2.credentials=sshcred
##  remo2 is a remote object for the repo
>>> remo2.url
u'https://github.com/avckp/sansa-pygit.git'
>>> remo2.push_url = remo2.url
>>> remo2.push('refs/heads/master')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "pygit2/remote.py", line 301, in push
    check_error(err)
  File "pygit2/errors.py", line 57, in check_error
    raise GitError(message)
GitError: HTTP parser error: the on_headers_complete callback failed

1 个答案:

答案 0 :(得分:0)

Keypair中的用户名应为'git',如#428所述。

应该是:

sshcred = repo_.pygit2.credentials.Keypair('git','/path/to/id_rsa.pub','/path/to/id_rsa','')
remo.crendentals = sshcred

然后再试一次。