How to get an unpublished commit account using GitPython?

With git status I can get information about the number 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 invoice) using GitPython. I documented that I found repo.git.status() , but that is not what I want.

+2
source share
1 answer

The command you are looking for is:

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

or if you want it to be like a list:

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

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

+4
source

All Articles