How to get count of unpublished commit with GitPython?

╄→гoц情女王★ 提交于 2019-12-23 19:59:22

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/15849640/how-to-get-count-of-unpublished-commit-with-gitpython

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!