【发布时间】:2017-05-14 12:59:54
【问题描述】:
我正在尝试使用 GitPython 从我的 Github 帐户中提取一个 repo。这是在
之后(1) 我已经从命令行执行了一个 git clone。
(2) 使用
生成新的 SSH 密钥ssh-keygen -t rsa -b 4096
(3) 在 Github 中将上述 #2 中的 .pub 文件的内容设置为新的 SSH 密钥。
我仍然被提示输入我的 Github 用户名和密码。这是为什么呢?
这是我的 .git 文件夹中的配置。注意 url 中的 http:// 而不是 https://
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = http://github.com/githubuser/myrepo.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
这是我的代码 sn-p
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)
【问题讨论】:
-
你修改了私钥吗?
标签: python git github ssh gitpython