拉后,GitPython在工作副本中不会显示任何内容 [英] GitPython nothing appears in working copy after pull

查看:118
本文介绍了拉后,GitPython在工作副本中不会显示任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PythonGit中的新成员,并且在推拉时遇到问题。我创建了本地裸回购并推送给它一个初始提交。之后,我尝试使用PythonGit启动新的用户回购,取回并从中取出。我没有问题初始化回购,但我无法从远程/裸回购任何东西。我的代码:

I'm new in PythonGit and I have problem with pulling and pushing. I created locally bare repo and pushed to it an initial commit. After that I tried to init new user repo using PythonGit, fetch it and pull from it. I have no problem with initialize the repo however I can't get anything from remote/bare repo. My code:

import git

repo = git.Repo.init('.')
origin = repo.create_remote('origin', '/home/paweber/git/my-repo.git')
origin.fetch()            
repo.create_head('master', origin.refs.master).set_tracking_branch(origin.refs.master)
origin.pull()

在用于提取和拉取的ipython控制台中,我得到:

In ipython console for fetch and pull I get:

In [5]: origin.fetch()
Out[5]: [<git.remote.FetchInfo at 0x7f4a4d6ee630>]

/ p>

for fetch and

In [6]: origin.pull()
Out[6]: [<git.remote.FetchInfo at 0x7f4a4d6e6ee8>]

为拉。拉动作后,根本没有任何东西被拉动,回购仍然是空的,但存在。我做错了什么?

for pull. After pull action, nothing is pulled at all and repo is still empty but exists. What I'm doing wrong?

推荐答案

pull() doesn'因为 master 已经在其目标提交中,所以 origin / master 。

pull() doesn't do anything as master is already at its destination commit, the one pointed to by origin/master.

此代码将按预期工作:

This code will work as expected:

import git

repo = git.Repo.init('.')
origin = repo.create_remote('origin', '/home/paweber/git/my-repo.git')
origin.fetch()
# the HEAD ref usually points to master, which is 'yet to be born'            
repo.head.ref.set_tracking_branch(origin.refs.master)
origin.pull()

这篇关于拉后,GitPython在工作副本中不会显示任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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