Respond to git command line prompt from Python program

I’m currently using a Python program to make automated commits to a repository after it makes some edits to a file. I am using subprocess.Popen to make a child process that calls the git binary. I though I could just use stdin=PIPE when creating the child process and be able to write my user credentials when prompted by the command line, but for some reason this isn’t happening. The code looks like the following:

proc = Popen(["git","push","origin","master"], stdin=PIPE)

What’s happening right now is that it’s calling the binary but still showing me the command line prompt. I’ve taken a look at some other questions on here, but they are all using essentially the same code I am, so I’m a little stumped as to the problem. I know there are plenty of other ways of achieving this result, like caching my credentials, but I’m curious to see if this way can work for a number of reasons.

  • Executing python subprocess via git hook
  • Python subprocess.Popen to use git pager
  • how to ammend the git commit message through python?
  • Git add through python subprocess
  • Make subprocess find git executable on Windows
  • Using back-ticks in Python subprocess
  • How to correctly call a git submodule symlinked?
  • Why does my post-receive hook hang while reading from a subprocess pipe?
  • One Solution collect form web for “Respond to git command line prompt from Python program”

    proc = Popen(["git","push","origin","master"], stdin=PIPE,stdout=PIPE,stderr=PIPE)
    #or maybe
    for letter in "password":
    print proc.communicate()

    something like that i guess …

    Git Baby is a git and github fan, let's start git clone.