You can use:
var=$(git status 2>&1)
i.e. redirect stderr to stdout and then capture the output.
Otherwise when for error messages are written on stderr and your command: var=$(git status) is only capturing stdout.
You can use:
var=$(git status 2>&1)
i.e. redirect stderr to stdout and then capture the output.
Otherwise when for error messages are written on stderr and your command: var=$(git status) is only capturing stdout.