I'm trying to update a Python script that checks the status of a handful of local repositories against remotes from using subprocess to using GitPython. What is the equivalent command in GitPython for git remote show origin
, or what is the better way to check that the local repo is fast-forwardable or out-of-date (etc.)?
$ git remote show origin
* remote origin
Fetch URL: <url>
Push URL: <url>
HEAD branch: master
Remote branches:
XYZ tracked
master tracked
Local branches configured for 'git pull':
XYZ merges with remote XYZ
master merges with remote master
Local refs configured for 'git push':
XYZ pushes to XYZ (up to date)
master pushes to master (up to date)
The last two lines are my primary concern. It looks like this might be possible with GitPython by iterating over git.Repo.heads
and git.Repo.remotes.origin.refs
and comparing .master.commit
(etc.) hashes. This seems a good deal more work than the above single native git command and will require even more work to tell which side(s) is/are outdated. I was expecting something like git.Repo.remotes.origin.status()
. What is the proper way to determine this in GitPython?