4

I would like to add and commit to local git repository using PHP code

I new babies in github ,so I don't understand in path on github path git.exe at C:\Users\Administrator\AppData\Local\GitHub\PortableGit_054f2e797ebafd44a30203088cd3d58663c627ef\libexec\git-core

path of repo 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' ");

it don't work. Help me pls

thanks

2 Answers 2

8

I use http://github.com/kbjr/Git.php it work!

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'); 
Sign up to request clarification or add additional context in comments.

Comments

1

Try configure git commit with author's parameters, it works fine to me:

shell_exec('git -c user.name="www-data" -c user.email="[email protected]" commit -m "commit form php" ');

The errors can be found in the server error file: /var/log/apache2/error.log

cat /var/log/apache2/error.log

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.