如何使用GitPython获得未发布的提交数量? [英] How to get count of unpublished commit with GitPython?

查看:138
本文介绍了如何使用GitPython获得未发布的提交数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 git status 我可以获得关于未发布的提交数量的信息:

 »git status 
#在分支master上
#你的分支在2次提交之前超过'origin / master'。
#(使用git push发布你的本地提交)

没有提交,工作目录干净

我想用GitPython获得未发布的提交(或计数)。我发现我发现 repo.git.status(),但这不是我想要的。

解决方案

您正在查找的命令是:

  repo.iter_commits('BRANCH..BRANCH @ {u}')

或者您想将其作为列表:

  list(repo.iter_commits('BRANCH..BRANCH @ {u}'))
$ b BRANCH @ {u} 语法引用 BRANCH


With git status I can get information about count of unpublished commits:

» git status             
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#   (use "git push" to publish your local commits)
#
nothing to commit, working directory clean

I want to get unpublished commits (or count) with GitPython. I docs I found repo.git.status(), but this is not what I want.

解决方案

The command you are looking for is:

repo.iter_commits('BRANCH..BRANCH@{u}')

or if you want this as a list:

list(repo.iter_commits('BRANCH..BRANCH@{u}'))

The BRANCH@{u} syntax refers to the upstream branch of BRANCH.

这篇关于如何使用GitPython获得未发布的提交数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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