title: Python: fatal: not a git repository Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)
body: <p>When I run</p>
  <pre><code>proc = subprocess.Popen(['git', 'add', '-A'], stdout=subprocess.PIPE)
  </code></pre>
  <p>I get this error</p>
  <pre><code>fatal: not a git repository (or any parent up to mount point /media)
  Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
  </code></pre>
  <p>But running</p>
  <pre><code>os.system('git add -A')
  </code></pre>
  <p>Does the job perfectly.</p>
  <p>If you think the folder does not have a <code>.git</code> file,</p>
  <pre><code>proc = subprocess.Popen(['ls', '-a'], stdout=subprocess.PIPE)
  </code></pre>
  <p>shows that it is already in the cwd.</p>
  <p>Why <code>Popen</code> cannot stage the files, nor can it do the commit while <code>os.system</code> does both?</p>
  <hr />
  <p><strong>Update:</strong></p>
  <p>Here is my failed MWE</p>
  <pre><code>import subprocess
  import os
  
  cwd = os.getcwd()
  proj_path = os.path.join(cwd, 'newproj')
  os.makedirs(proj_path)
  os.chdir(proj_path)
  proc = subprocess.Popen(['git', 'init'], stdout=subprocess.PIPE)
  proc = subprocess.Popen(['ls', '-a'], stdout=subprocess.PIPE)
  print(proc.stdout.read().decode('ascii'))
  proc = subprocess.Popen(['git', 'add', '-A'], stdout=subprocess.PIPE)
  out, err = proc.communicate()
  if err:
      print('Error:\n', err.decode())
  print(out.decode('ascii'))
  </code></pre>
  <p>output</p>
  <pre><code>.
  ..
  .git
  
  fatal: not a git repository (or any parent up to mount point /media)
  Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
  </code></pre>