- --is-inside-work
import subprocess, os repo_dir = os.path.expanduser('~/git/dchelper') command = ['git', 'rev-parse', '--is-inside-work-tree'] process = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=repo_dir) output = process.communicate() # (b'true\n', None) res = output[0].decode().strip() if res == 'true': print('--is-inside-work-tree')