如何使用GitPython提取远程存储库? [英] How can I pull a remote repository with GitPython?

查看:264
本文介绍了如何使用GitPython提取远程存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到使用gitPython提取git存储库的方法. 到目前为止,这是我从官方文档此处摘录的内容

I am trying to find the way to pull a git repository using gitPython. So far this is what I have taken from the official docs here.

test_remote = repo.create_remote('test', 'git@server:repo.git')
repo.delete_remote(test_remote) # create and delete remotes
origin = repo.remotes.origin    # get default remote by name
origin.refs                     # local remote references
o = origin.rename('new_origin') # rename remotes
o.fetch()                       # fetch, pull and push from and to the remote
o.pull()
o.push()

事实是,我想访问repo.remotes.origin进行拉取,而无需重命名其来源(origin.rename) 我怎样才能做到这一点? 谢谢.

The fact is that I want to access the repo.remotes.origin to do a pull withouth renaming it's origin (origin.rename) How can I achieve this? Thanks.

推荐答案

我通过直接获取存储库名称来进行管理:

I managed this by getting the repo name directly:

 repo = git.Repo('repo_name')
 o = repo.remotes.origin
 o.pull()

这篇关于如何使用GitPython提取远程存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆