How can I use GitPython to determine:
- My local branch is ahead of the remote one (I can safely click)
- My local branch is behind the remote control (I can pull it out safely)
- Has my local branch deviated from the console?
To check if local and remote are the same, I do 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
Lorin hochstein
source share