dpn68721 2017-02-04 02:46
浏览 331

从PHP脚本中运行git命令

I have a file upload form and after the file uploads I want to push the files up to GitHub by running:

git add .
git commit -m "some message"
git push origin master

How do I go about this? I've seen examples of using exec() but that makes me nervous.

shell_exec('cd /var/www/vhost/xxx.com/httpdocs/clients/portal/upoads/54 && /usr/bin/git add -A');
shell_exec('cd /var/www/vhost/xxx.com/httpdocs/clients/portal/upoads/54 && /usr/bin/git commit -m "something 1"');
shell_exec('cd /var/www/vhost/xxx.com/httpdocs/clients/portal/upoads/54 && /usr/bin/git push origin master');

Those commands don't error but don't work either. Do I need to grant access to the apache user to use the ssh key?

  • 写回答

3条回答 默认 最新

  • dsfs21312 2017-02-04 03:10
    关注

    i guess is permission problems, you can use exec() , and get the error info by $output

    exec($your_command.' 2>&1', $output, $return_var);
    var_dump($output);
    
    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能