Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 什么';使用PyPi通过git克隆传递令牌的正确方法是什么?_Python_Git_Pypi - Fatal编程技术网

Python 什么';使用PyPi通过git克隆传递令牌的正确方法是什么?

Python 什么';使用PyPi通过git克隆传递令牌的正确方法是什么?,python,git,pypi,Python,Git,Pypi,我正在使用PyPi克隆github存储库,但是它是一个私有的repo。所以我还需要用我的代币授权。我找不到任何关于如何通过克隆请求传递令牌的示例 import git git.Git('/local/file/path').clone('git@github.com:sample-repo.git', token=(mytoken)) 这是一个错误 “GitCommandError:Cmd('git')失败,原因是:退出代码(129)” cmdline:git clone--token=myt

我正在使用PyPi克隆github存储库,但是它是一个私有的repo。所以我还需要用我的代币授权。我找不到任何关于如何通过克隆请求传递令牌的示例

import git
git.Git('/local/file/path').clone('git@github.com:sample-repo.git', token=(mytoken))
这是一个错误

“GitCommandError:Cmd('git')失败,原因是:退出代码(129)”
cmdline:git clone--token=mytokengit@github.com:sample-repo.git
stderr:'错误:未知选项标记=mytoken'


当我尝试克隆公共存储库时,如果没有令牌,它可以正常工作。因此,这里唯一的问题是如何将令牌传递给上述请求。这是可能的,还是有其他方法可以在python脚本中授权git克隆?我的目标是自动化一个过程来克隆github存储库,使用一些API调用生成一些文件,将这些文件添加并提交到存储库,所有这些都在同一个python脚本中。

由于这些注释,我能够使用https url而不是ssh url来克隆存储库,并且它不需要令牌

import git
git.Git('/local/file/path').clone('https://github.com/sample-repo')

多亏了这些评论,我才能够使用https url而不是ssh url克隆我的存储库,而且它可以在不需要令牌的情况下工作

import git
git.Git('/local/file/path').clone('https://github.com/sample-repo')

要使用GitHub访问令牌,必须使用https URL而不是ssh URL。有关详细信息,请参阅。该令牌用于GitHub的REST API,而不是git本身。感谢您的澄清。它使用https URL要使用GitHub访问令牌,必须使用https URL而不是ssh URL。有关详细信息,请参阅。该令牌用于GitHub的REST API,而不是git本身。感谢您的澄清。它与https url一起工作