0

I am using GitPython,

I am trying to somehow see if all my local commits where push to the remote server. I can see differences between my current local state and master doing this :

import git
t = repo.heads['master'].commit.tree
repo.git.diff(t)

but I can't figure out how to check if commits where pushed or not

Steven G
  • 16,244
  • 8
  • 53
  • 77
  • Not related to git python, but usually you can do this using `git log origin/master..master`. – mvp Jan 23 '19 at 19:47

2 Answers2

0

thanks to @mvp

you can use repo.git.log('origin/master..master')

Steven G
  • 16,244
  • 8
  • 53
  • 77
0

try this

from git import *

repo = Repo("YOUR_GIT_REPO")
unpushed_commits = list(repo.iter_commits('origin/master..master'))

first_commit = unpushed_commits[0]
print(first_commit.author)
wzwu
  • 1
  • 2