Skip to content

Latest commit

 

History

History
133 lines (75 loc) · 1.82 KB

git_branch_command.md

File metadata and controls

133 lines (75 loc) · 1.82 KB

Git Branches

Use the interface: ArtARTs36\GitHandler\Contracts\Commands\GitBranchCommand


Create Instance

use \ArtARTs36\GitHandler\Factory\LocalGitFactory;

$command = (new LocalGitFactory())->factory(__DIR__)->branches();

Features:

* Delete Branch

Method Signature:

public function delete(string $branch): bool;

Equals Git Command:

git branch -d {$branch}

Example:

use \ArtARTs36\GitHandler\Factory\LocalGitFactory;

(new LocalGitFactory())->factory(__DIR__)->branches()->delete('master');

* Create new Branch

Method Signature:

public function create(string $branch): void;

Equals Git Command:

git branch {$branch}

Example:

use \ArtARTs36\GitHandler\Factory\LocalGitFactory;

(new LocalGitFactory())->factory(__DIR__)->branches()->create('master');

* Get all Branches

Method Signature:

public function getAll(): string[];

Equals Git Command:

git branch -a

Example:

use \ArtARTs36\GitHandler\Factory\LocalGitFactory;

(new LocalGitFactory())->factory(__DIR__)->branches()->getAll();

* Switch to Branch

Method Signature:

public function switch(string $branch): bool;

Equals Git Command:

git switch {$branch}

Example:

use \ArtARTs36\GitHandler\Factory\LocalGitFactory;

(new LocalGitFactory())->factory(__DIR__)->branches()->switch('master');

* Get current Branch

Method Signature:

public function current(): ArtARTs36\Str\Str;

Equals Git Command:

git branch --show-current

Example:

use \ArtARTs36\GitHandler\Factory\LocalGitFactory;

(new LocalGitFactory())->factory(__DIR__)->branches()->current();