title: Python script to determine if a directory is a git repository
body: <p>I have just started with Python and my first assignment is to write a script to determine if a directory where it is ran is a git repository. A co-student suggested this code:</p>
  
  <pre><code>#! /usr/bin/env python
  
  from subprocess import Popen, PIPE, STDOUT
  if Popen(("git", "branch"), stderr=STDOUT, stdout=PIPE).returncode != 0:
      print("Nope!")
  else:
      print("Yup!")
  </code></pre>
  
  <p>It should print an output depending on what the returncode of console command "git branch" is. However, the script did not work in the repository.</p>
  
  <p>In any case, I would be grateful for any piece of advice regarding this.</p>
  
  <p>The assignment also includes:</p>
  
  <ul>
  <li>being able to use same script on Windows</li>
  <li>eventual passing of the path to determine to the script without having to copy it to the target directory</li>
  </ul>
  
  <p>Many thanks!</p>