I'm working with custom a build system that manages a large number of git repositories and written primarily in python.
It would save me a lot of time if I could write a command that would report the current branch of all repositories, then report if the head of "branch" is the same as the head of "remotes/origin/branch".
We already have a command that will run a shell command inside every git repository, what I'm looking for is a method of getting some simply formatted information from git with regards to the relative position of branch and remotes/origin/branch. Something which is either going to be number of commits difference or a simple boolean value.
What's the method of getting this information out of git which is going to minimize the amount of parsing and processing I've got to do on the python side?
git status shows how many commits you are ahead/behind the remote tracking branch. You need to perform git fetch first though, because otherwise git cannot know if anything new went into remote.
simplest possible way git can output the number of commits between "branch" and "remotes/origin/branch"