PHP code example of konekt / git-php
1. Go to this page and download the library: Download konekt/git-php 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' );
konekt / git-php example snippets
$git->command()->option()->execute();
GitRepository::in('/path/to/git/target/directory' )->init()->execute();
$git = GitRepository::in('/path/to/repo' );
$git->cloneRepository()->execute();
$annotatedTag = $git->describe()->execute();
$lightweightTag = $git->describe()->tags()->execute();
$recentRef = $git->describe()->all()->execute();
$git->remote()
->setUrl('origin' , 'git@github.com:bit3/git-php.git' )
->execute();
$git->remote()
->setPushUrl('origin' , 'git@github.com:bit3/git-php.git' )
->execute();
$git->remote()
->add('github' , 'git@github.com:bit3/git-php.git' )
->execute();
$git->fetch()->execute('github' );
$git->checkout()->execute('hotfix/1.2.3' );
$git->checkout()->execute('hotfix/1.2.3' , '/fileA' , '/fileB' , '/dir/fileC' );
$git->push()->execute('github' , 'hotfix/1.2.3' );
$git->add()->execute('file/to/add.ext' );
$git->rm()->execute('file/to/remove.ext' );
$git->commit()->message('Commit message' )->execute();
$git->tag()->execute('v1.2.3' );
$remotes = $git->remote()->getNames();
$remotes = $git->branch()->getNames();
$remotes = $git->branch()->remotes()->getNames();
$remotes = $git->branch()->all()->getNames();
$status = $git->status()->getStatus();
$status = $git->status()->getIndexStatus();
$status = $git->status()->getWorkTreeStatus();