【问题标题】:How to use PHP shell_exec upload GitHub?如何使用 PHP shell_exec 上传 GitHub?
【发布时间】:2017-07-12 07:08:09
【问题描述】:

我想用shell_exec推送到git服务器,怎么办?

<?php
    echo shell_exec('git add .');
    echo shell_exec('git commit -m"update"');
    echo shell_exec('git push origin master');
?>

[master 9471163] 更新提交者:非特权用户您的姓名和电子邮件地址是根据您的用户名和主机名自动配置的。请检查它们是否准确。您可以通过显式设置来禁止显示此消息。运行以下命令并按照编辑器中的说明编辑配置文件: git config --global --edit 完成此操作后,您可以使用以下命令修复用于此提交的身份: git commit --amend --reset-author 1 个文件更改,5 个插入(+)创建模式 100644 shell.php

【问题讨论】:

    标签: php github


    【解决方案1】:

    在控制台中发出这个来为 git 设置全局用户名和电子邮件:

    git config --global user.email "yourmail@address.com"
    git config --global user.name "Your name"
    

    【讨论】:

      【解决方案2】:

      您也可以使用su 以其他用户身份运行命令:

      su - username -c "command"
      

      ->

      echo shell_exec('su - username -c "git add ."');
      echo shell_exec('su - username -c "git commit -m \"update\""');
      echo shell_exec('su - username -c "git push origin master"');
      

      将“用户名”替换为您的 unix 登录名。

      【讨论】:

        猜你喜欢
        • 2021-09-20
        • 2014-09-19
        • 2014-04-26
        • 2011-04-02
        • 2015-08-13
        • 2018-08-13
        • 1970-01-01
        • 1970-01-01
        • 2021-05-15
        相关资源
        最近更新 更多