我正在尝试使用GitPython从我的Github帐户提取回购。这是之后
(1)我已经从命令行执行了一个git克隆。在
(2)使用ssh-keygen -t rsa -b 4096
(3)在Github中将上述#2中的.pub文件的内容设置为新的SSH密钥。在
仍然会提示我输入Github用户名和密码。为什么?在
这是我的.git文件夹中的配置。注意url中的http://而不是https://
^{pr2}$
这是我的代码片段import git, os
DIR_NAME = 'path/to/dir/with/gitfolder'
git_ssh_identity_file = os.path.expanduser('/path/to/rsa/key')
git_ssh_cmd = 'ssh -i %s' % git_ssh_identity_file
with git.Git().custom_environment(GIT_SSH_COMMAND=git_ssh_cmd):
repo = git.Repo.init(DIR_NAME)
origin = repo.remote()
refs = origin.refs
for ref in refs:
if ref.remote_head == "master":
origin.pull(ref.remote_head)