簡體   English   中英

用PHP / Symfony進行Git推送

[英]Make a Git push with PHP/Symfony

對於我的Symfony項目,我想提交並立即推送我上傳的圖像。 目前,只有推不起作用。 對於其他命令,我這樣做:

exec('git add myfile');
exec('git -c user.name="My User Name" -c user.email="my email" commit -m "My Commit"');

為了推動,我嘗試這樣做:

$branch = exec("git branch | grep \* | cut -d ' ' -f2");
exec('git push https_link '.$branch);

我沒有錯誤,沒有輸出,只是我的腳本等待了很長時間,我需要重新啟動Apache。 這是一個簡單的身份驗證(我在我的https上使用了專用於我的URL的bitbucket),然后不需要密碼。 我也嘗試使用proc_open,但這是相同的。 我看到了庫https://github.com/kbjr/Git.php,但是我沒有用Symfony安裝它

您將需要查找錯誤消息。 如果您使用的是Symfony,則應使用Process Component 很有可能是對位桶進行身份驗證的問題。 不要忘記,PHP通常在與您使用的用戶不同的環境下運行,因此所有SSH config / ENV變量都不同。

有了它,它將像

$process = new Process(array('ls', '-lsa'));
$process->run('git -c user.name="My User Name" -c user.email="my email" commit -m "My Commit"');
$output = $process->getOutput(); // here you should see the output - Time to find where is problem

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM