【问题标题】:Reading output of git push from PHP exec() function从 PHP exec() 函数读取 git push 的输出
【发布时间】:2012-11-14 23:58:18
【问题描述】:

我正在为我的框架的命令行工具编写一个部署命令。它使用 git 来部署。

我有这样一行:

exec("git push {$remote} {$branch}:{$branch}", $shell_output, $status);

我希望在$shell_output 内有推送的输出,但它没有发生(输出只显示在终端上)。我想是因为git 是一个外部程序,因此会创建一个新的输出流?

我尝试使用here 描述的输出缓冲区,但无济于事。我敢肯定 SO 上有一些东西可以回答这个问题,但经过大量挖掘后无法找到它..

所以任何帮助将不胜感激:)

【问题讨论】:

    标签: php git bash operating-system


    【解决方案1】:

    git 将其输出发送到 STDERR 而不是 STDOUT,因此您需要使用以下内容重定向它:

    git push REPO --progress 2>&1

    或文件:

    git push REPO --progress > /path/to/file 2>&1

    【讨论】:

    • 谢谢你,这就是我要找的:)
    猜你喜欢
    • 1970-01-01
    • 2011-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-01
    相关资源
    最近更新 更多