title: How do I capture output of git commands with python subprocess.Popen
body: <p>I am trying to run a git command with subprocess and store the output as a string. When I run the se commands in the interpreter, the git command prints its output but it is not stored. If I trade out 'git status' with 'ipconfig', the command runs flawlessly and I can retrieve its output.</p>
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; import subprocess as sp
  &gt;&gt;&gt; p = sp.Popen('git status', stdout = sp.PIPE) #this one prints the output of git status after the &gt;&gt;&gt; prompt is printed.
  &gt;&gt;&gt; a = p.communicate()
  &gt;&gt;&gt; a #is a tuple of (b'', None)
  </code></pre>
  <p>How do I capture the output of git commands with subprocess? Please do not mark this as a duplicate because I have tried solutions from all over the place. Some are listed here:</p>
  <p><a href="https://stackoverflow.com/questions/59022549/how-to-preserve-colors-when-capturing-output-from-git-commands">How to preserve colors when capturing output from Git commands?</a>
  <a href="https://www.pythonforbeginners.com/os/subprocess-for-system-administrators/" rel="nofollow noreferrer">https://www.pythonforbeginners.com/os/subprocess-for-system-administrators/</a></p>
  <p>No matter what code I use, it does not work if applied to a git command. I use Windows 10 and Python 3.7.8.</p>