我正在尝试使用GitPython从我的Github帐户中提取回购。这是在
之后(1)我已经从命令行执行了一个git clone。
(2)使用
生成新的SSH密钥ssh-keygen -t rsa -b 4096
(3)在Github上面的#2中设置.pub文件的内容作为新的SSH密钥。
我仍然会收到提示输入我的Github用户名和密码的提示。那是为什么?
这是我的.git文件夹中的配置。请注意网址中的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
这是我的代码段
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)
答案 0 :(得分:1)
请注意网址中的http://而不是https://4
只要您使用的是http(s)网址,ssh根本不会用于身份验证。
您需要一个ssh网址:
override func viewDidLayoutSubviews() {
self.collectionView?.setContentOffset(CGPoint.zero, animated: false)
}
http url仍然依赖于用户名/密码身份验证方案 只有ssh网址才会使用您的公钥/私钥。