Here is a very specific question, but I'm looking for a slightly more general solution:
I am writing a shell script in Python to help with various configuration tasks, including executing the git clone
various repositories. When I call git clone
, is there a good way to output git output directly to the terminal (progress bars, etc.)?
Just laying out the stdout subprocess in sys.stdout does not shorten it, because git
behavior involves rewriting over the same part of the terminal, which indicates progress. So this is not very good:
import sys, subprocess process = subprocess.Popen("git clone --recursive https://github.com/my/repo.git", shell=True, stdout=sys.stdout, stderr=subprocess.PIPE)
I'm not looking for the answer to "use git -python" - rather, I'm looking for a more general method that I can apply to this and other configuration tasks.
Thanks!
source share