python - GitPython pull/fetch 检索进度

标签 python gitpython

拉/取时如何检索文件列表?假设设置上游并拉动上游。

repo = git.Repo('/repo_location/')
result = repo.git.pull()

根据 API 引用,它说返回是可迭代列表。但我无法那样使用它。

如果我执行 print(result),它会正确地打印到标准输出,但在我迭代时不会。

最佳答案

我发现没有 gitpython 方法可以执行此操作,所以我执行了 git diff-tree:

repo = Repo(repo_dir)
# first get the remote information to get all changed files, than pull the repository
# has to be done in this order, because after pulling the local repository does not differ from the remote
repo.remote().fetch()
repo.remote().pull()
# the "-t"-option also lists all changed directories
diff_tree = repo.git.execute('git diff-tree --name-status -t master origin/master')

for line in diff_tree.splitlines():
    change_status, file_path = line.split('\t')

关于python - GitPython pull/fetch 检索进度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36054492/

相关文章:

python - 按 col Y 分组时在 pandas DataFrame 的 col X 中查找最小值

使用用户名和密码的 gitpython git 身份验证

python - GitPython:如何使用 '--no-ff' pull 远程存储库?

python - 使用GitPython读取Git运行进度卡住

Python导入机制和模块模拟

python - pip 没有将 entry_points 安装为可执行文件

python - Ctrl + C 没有停止程序

python - 将列表的字符串转换为整数列表

ssl - 使用 GitPython 库的 git clone

python - gitpython 使用 PYTHON 检查文件是否有任何更改