GitPython 管道输出到标准输出

GitPython pipe output to stdout

在 python 中编写一些非常简单的脚本。我在 python 脚本中使用以下语句将存储库克隆到服务器:

Repo.clone_from("source", "target")

如何从 clone_from 获取进度并将其通过管道传输到标准输出?

您可以使用您正在使用的git.remote.RemoteProgress as third parameter for the class method clone_from(url, to_path, progress=None, env=None, **kwargs)

class Progress(RemoteProgress):
    def line_dropped(self, line):
        print line
    def update(self, *args):
        print self._cur_line