refactoring some duplicate related to git

Add a new function which wraps shell command and returns the output as a
string. Mainly used for git related command.