innmind / git
Git abstraction
4.0.0
2025-08-09 15:49 UTC
Requires
- php: ~8.2
- innmind/foundation: ^1.7.1
Requires (Dev)
- innmind/black-box: ~6.5
- innmind/coding-standard: ~2.0
- innmind/static-analysis: ^1.2.1
- symfony/filesystem: ~6.0|~7.0
- dev-develop
- 4.0.0
- 3.2.0
- 3.1.0
- 3.0.2
- 3.0.1
- 3.0.0
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
- dev-master
- dev-better-types
- dev-cs
- dev-reuse-workflows
- dev-better-error-handling
- dev-update-dependencies
- dev-static-analysis
- dev-no-discard-attributes
- dev-use-blackbox-6
- dev-license-date-range
- dev-fix-php-84-deprecations
This package is auto-updated.
Last update: 2025-08-09 15:49:49 UTC
README
Abstraction layer to manipulate local git repositories.
Feel free to submit a PR to add other git functionalities.
Installation
composer require innmind/git
Usage
use Innmind\Git\{ Git, Repository\Remote\Name, Repository\Remote\Url, Revision\Branch, }; use Innmind\OperatingSystem\Factory; use Innmind\Url\Path; $os = Factory::build(); $git = Git::of($os->control(), $os->clock()); $repository = $git ->repository(Path::of('/somewhere/on/the/local/machine')) ->unwrap(); $_ = $repository ->init() ->unwrap(); $remotes = $repository->remotes(); $remotes ->add(Name::of('origin'), Url::of('git@github.com:Vendor/Repo.git')) ->unwrap(); $remotes ->get(Name::of('origin')) ->push(Branch::of('master')) ->unwrap(); $repository ->branches() ->new(Branch::of('develop')) ->unwrap(); $repository ->checkout() ->revision(Branch::of('develop')) ->unwrap();
This example initialize a local git repository, declare a github repository as its remote and finally checkout the new branch develop
.
The offered functionalities goes beyond this single example, check the classes' api to discover all of them.