You are probably not issuing the command in correct folder, where git is initialized.
Your actual problem is, that os.path.dirname
command is striping out the folder from the command os.getcwd
and you are actually running the command in parent folder. If you get rid of os.path.dirname
and just use os.getcwd
your code should work.