PHP code example of sebastianfeldmann / git

1. Go to this page and download the library: Download sebastianfeldmann/git library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sebastianfeldmann / git example snippets


$repoRootPath  = '/var/www/my-project';
$gitRepository = new Git\Repository($repoRootPath);

$log = $gitRepository->getLogOperator();

$files   = $log->getChangedFilesSince('1.0.0');
$commits = $log->getCommitsSince('1.0.0');

use SebastianFeldmann\Git;

out .git
$repoRootPath  = '/path/to/repo';
$gitRepository = new Git\Repository($repoRootPath);

// get files and commits since hash or tag
$log     = $gitRepository->getLogOperator();
$files   = $log->getChangedFilesSince('1.0.0');
$commits = $log->getCommitsSince('1.0.0');

// check the index status
$index = $gitRepository->getIndexOperator();
$files = $index->getStagedFiles();