使用 GitPython 库进行 git 克隆

Pet*_*etr 3 ssl gitpython

如何使用 GitPython 库在禁用 SSL 检查的情况下进行克隆。下面的代码...

import git
x = git.Repo.clone_from('https://xxx', '/home/xxx/lala')
Run Code Online (Sandbox Code Playgroud)

...产生此错误:

Error: fatal: unable to access 'xxx': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
Run Code Online (Sandbox Code Playgroud)

我知道“export GIT_SSL_NO_VERIFY=1”,但是如何在 python 库中实现它?

buf*_*ufh 6

以下两种方法已经使用 GitPython 2.0.8 进行了测试,但至少应该从 1.0.2 开始工作(来自文档)。

正如@Byron建议的:

git.Repo.clone_from(
  'https://example.net/path/to/repo.git',
  'local_destination',
  branch='master', depth=1,
  env={'GIT_SSL_NO_VERIFY': '1'},
)
Run Code Online (Sandbox Code Playgroud)

正如@Christopher建议的:

git.Repo.clone_from(
  'https://example.net/path/to/repo.git',
  'local_destination',
  branch='master', depth=1,
  config='http.sslVerify=false',
)
Run Code Online (Sandbox Code Playgroud)