Use the interface: ArtARTs36\GitHandler\Contracts\Commands\GitIndexCommand
use \ArtARTs36\GitHandler\Factory\LocalGitFactory;
$command = (new LocalGitFactory())->factory(__DIR__)->index();
public function add(string|string[] $file, bool $force = false): bool;
git add $file
git add $file $file $file
use \ArtARTs36\GitHandler\Factory\LocalGitFactory;
(new LocalGitFactory())->factory(__DIR__)->index()->add('file-test', true);
public function remove(string|string[] $files, bool $force = false): void;
git rm $file
git rm $file1 $file2 ...
use \ArtARTs36\GitHandler\Factory\LocalGitFactory;
(new LocalGitFactory())->factory(__DIR__)->index()->remove('files-test', true);
public function removeCached(string|string[] $files, bool $force = false): void;
git rm --cached $file
git rm --cached $file1 $file2 ...
use \ArtARTs36\GitHandler\Factory\LocalGitFactory;
(new LocalGitFactory())->factory(__DIR__)->index()->removeCached('files-test', true);
See classes:
public function reset(ResetMode $mode, string $subject): void;
git reset --$mode $subject
use \ArtARTs36\GitHandler\Factory\LocalGitFactory;
(new LocalGitFactory())->factory(__DIR__)->index()->reset(ResetMode::from(ResetMode::SOFT), 'subject-test');
See classes:
public function resetHead(ResetMode $mode): void;
git reset --$mode HEAD~
use \ArtARTs36\GitHandler\Factory\LocalGitFactory;
(new LocalGitFactory())->factory(__DIR__)->index()->resetHead(ResetMode::from(ResetMode::SOFT));
public function rollback(string|string[] $paths): void;
git checkout HEAD $paths
use \ArtARTs36\GitHandler\Factory\LocalGitFactory;
(new LocalGitFactory())->factory(__DIR__)->index()->rollback('paths-test');
public function checkout(string $path, bool $merge = false): bool;
git checkout $path
use \ArtARTs36\GitHandler\Factory\LocalGitFactory;
(new LocalGitFactory())->factory(__DIR__)->index()->checkout('/path/to/file', true);
public function cherryPick(string $commitSha): void;
git cherry-pick $commitSha
use \ArtARTs36\GitHandler\Factory\LocalGitFactory;
(new LocalGitFactory())->factory(__DIR__)->index()->cherryPick('commitSha-test');