如何在GitPython中使用GitPull?
我试图使用python从git中提取文件,但它不起作用。下面是我使用的代码:如何在GitPython中使用GitPull?,python,git,git-pull,gitpython,pygit2,Python,Git,Git Pull,Gitpython,Pygit2,我试图使用python从git中提取文件,但它不起作用。下面是我使用的代码: import git git.cmd.Git().pull('https://github.com/User/repo','master') 它请求身份验证,然后终止 有人能帮我吗?此代码有什么问题?这取决于您的操作系统,但您应该使用a来缓存密码(或者如果您有) 这是假设您正在尝试从私有存储库中提取 from git import Repo # rorepo is a Repo instance pointin
import git
git.cmd.Git().pull('https://github.com/User/repo','master')
它请求身份验证,然后终止
有人能帮我吗?此代码有什么问题?这取决于您的操作系统,但您应该使用a来缓存密码(或者如果您有) 这是假设您正在尝试从私有存储库中提取
from git import Repo
# rorepo is a Repo instance pointing to the git-python repository.
# For all you know, the first argument to Repo is a path to the repository
# you want to work with
repo = Repo(self.rorepo.working_tree_dir)
assert not repo.bare
例如,在Windows上,这将是“
manager
”,您可以使用缓存凭据。第一步是创建一个git.Repo
对象来表示您的存储库
from git import Repo
# rorepo is a Repo instance pointing to the git-python repository.
# For all you know, the first argument to Repo is a path to the repository
# you want to work with
repo = Repo(self.rorepo.working_tree_dir)
assert not repo.bare
在上面的示例中,目录self.rorepo.working_tree_dir
等于/Users/mtrier/Development/git python
,是我的工作存储库,其中包含.git
目录。您还可以使用裸存储库初始化GitPython
from git import Repo
# rorepo is a Repo instance pointing to the git-python repository.
# For all you know, the first argument to Repo is a path to the repository
# you want to work with
repo = Repo(self.rorepo.working_tree_dir)
assert not repo.bare
这就是你想要的:
repo = git.Repo('repo_name')
o = repo.remotes.origin
o.pull()
是的,但在提供凭据之后,它应该会被git拉,但我无法看到我的folder@ZZ3111然后直接用git测试它,看看是否发生了同样的问题