问题
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