How can I use GitPython to determine whether:
- My local branch is ahead of the remote (I can safely push)
- My local branch is behind the remote (I can safely pull)
- My local branch has diverged from the remote?
To check if the local and remote are the same, I'm doing this:
def local_and_remote_are_at_same_commit(repo, remote):
local_commit = repo.commit()
remote_commit = remote.fetch()[0].commit
return local_commit.hexsha == remote_commit.hexsha