git: simplify command line interaction by refactoring run_cmd