ausi / remote-git
Edit git repositories remotely
Fund package maintenance!
ausi
Requires
- php: ^8.0
- symfony/filesystem: ^5.3 || ^6.0
- symfony/process: ^5.3 || ^6.0
Requires (Dev)
- contao/easy-coding-standard: ^6.3.1
- phpstan/phpstan: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-symfony: ^1.0
- phpunit/phpunit: ^9.5.8
- psalm/plugin-phpunit: ^0.18
- slam/phpstan-extensions: ^6.0
- symfony/console: ^5.3 || ^6.0
- vimeo/psalm: ^5.13
README
This library provides methods to handle git repositories remotely without having to clone the whole repo. It uses the Symfony process component to run the git client.
Usage
<?php use Ausi\RemoteGit\Repository; use Ausi\RemoteGit\GitObject\File; use Ausi\RemoteGit\Exception\ConnectionException; use Ausi\RemoteGit\Exception\PushCommitException; $repo = new Repository('ssh://git@github.com/ausi/remote-git.git'); try { $repo->connect(); } catch(ConnectionException $exception) { // Unable to connect to the specified server } $headCommit = $repo->getBranch('main')->getCommit(); $newTree = $headCommit ->getTree() ->withFile( 'example.txt', 'Example content…', ) ; $newCommit = $repo->commitTree($newTree, 'Add example', $headCommit); try { $repo->pushCommit($newCommit, 'main'); } catch(PushCommitException $exception) { // Unable to push to the specified remote, e.g. no write access }
Installation
To install the library use Composer or download the source files from GitHub.
composer require ausi/remote-git
Speed
Speed comparison of cloning https://gitlab.com/linux-kernel/stable.git and reading the contents of a file:
Naturally, this is strongly dependent on many factors like bandwidth and CPU power and should only give a rough idea of this projects purpose, namely reading or writing small bits of data from or to a remote GIT repository.