What I want is to store the output of a git command (such as git status) inside a variable in a shell script. When I say output, I am talking about the text returned in the terminal on execution of a command, for example: on doing a git status outside my repo:
fatal: Not a git repository (or any of the parent directories): .git
I tried this:
var=$(git status)
But 'var' did not store anything.
varwill contain what was sent to STDOUT. You could use2>&1to redirect the former to the latter.