【问题标题】:how to commit github using php如何使用 php 提交 github
【发布时间】:2014-03-07 02:25:35
【问题描述】:

我想使用 PHP 代码添加并提交到本地 git 存储库

我是 github 的新手,所以我不明白 github 上的路径 路径 git.exe 在 C:\Users\Administrator\AppData\Local\GitHub\PortableGit_054f2e797ebafd44a30203088cd3d58663c627ef\libexec\git-core

回购路径 C:\Users\Administrator\Documents\GitHub\confre

    $path = "C:\Users\Administrator\Documents\GitHub\confre"; 
chdir($path);
echo shell_exec("git add . ");  
echo shell_exec("git commit -m 'commit form php' ");

它不起作用。请帮帮我

谢谢

【问题讨论】:

    标签: php git github yii


    【解决方案1】:

    我使用http://github.com/kbjr/Git.php 它工作!

    require_once('Git.php');  
    $repo = Git::open('gitphp');  // -or- Git::create('/path/to/repo')
    $repo->run(' config  user.email "your email"'); 
    $repo->run(' config  user.name "your username"');   
    echo $repo->run(' log -p'); 
    

    【讨论】:

      【解决方案2】:

      尝试使用作者的参数配置 git commit,它对我来说很好:

      shell_exec('git -c user.name="www-data" -c user.email="no-replay@example.org" commit -m "commit form php" ');
      

      错误可以在服务器错误文件中找到:/var/log/apache2/error.log

      cat /var/log/apache2/error.log
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-03-28
        • 2014-09-22
        • 2022-10-14
        • 2011-06-14
        • 2013-05-27
        • 2015-10-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多