I would like to extract the information that is printed after a git status
, which looks like:
# On branch master
# Your branch is ahead of \'origin/
With recent versions of git you should use
git status --porcelain --branch
and check for ahead/behind:
## master...origin/master [behind 1]
--porcelain[=version]
Give the output in an easy-to-parse format for scripts. This is similar to the short output, but will remain stable across Git versions and regardless of user configuration. See below for details.
-b, --branch
Show the branch and tracking info even in short-format.