Monday, June 23, 2014

Shell - Set GIT command output to variable

Just small note... I tried to make some shell script which works with GIT commands. So, I need to set shell output to some variable.
var=$(git pull)

I cannot do that with such approach. It always show me result.
The answer I found by link.
So we need to add a little change:
var=$(git pull 2>&1)

# or
var=$(git pull > /dev/null 2>&1)
Post a Comment