How to get count of unpublished commit with GitPython?
问题 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