Overview

Namespaces

  • CzProject
    • GitPhp

Classes

  • GitRepository
  • Helpers

Exceptions

  • Exception
  • GitException
  • StaticClassException
  • Overview
  • Namespace
  • Class

Class GitRepository

Namespace: CzProject\GitPhp
Located at GitRepository.php
Methods summary
public
# __construct( string $repository )

Parameters

$repository

Throws

CzProject\GitPhp\GitException
public string
# getRepositoryPath( )

Returns

string
public static
# createTag( string $name, array|null $options = NULL )

Creates a tag. git tag <name>

Creates a tag. git tag <name>

Parameters

$name
$options

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# removeTag( string $name )

Removes tag. git tag -d <name>

Removes tag. git tag -d <name>

Parameters

$name

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# renameTag( string $oldName, string $newName )

Renames tag. git tag <new> <old> git tag -d <old>

Renames tag. git tag <new> <old> git tag -d <old>

Parameters

$oldName
$newName

Returns

static

Throws

CzProject\GitPhp\GitException
public string[]|null
# getTags( )

Returns list of tags in repo.

Returns list of tags in repo.

Returns

string[]|null
NULL => no tags

Throws

CzProject\GitPhp\GitException
public static
# merge( string $branch, array|null $options = NULL )

Merges branches. git merge <options> <name>

Merges branches. git merge <options> <name>

Parameters

$branch
$options

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# createBranch( string $name, boolean $checkout = FALSE )

Creates new branch. git branch <name> (optionaly) git checkout <name>

Creates new branch. git branch <name> (optionaly) git checkout <name>

Parameters

$name
$checkout

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# removeBranch( string $name )

Removes branch. git branch -d <name>

Removes branch. git branch -d <name>

Parameters

$name

Returns

static

Throws

CzProject\GitPhp\GitException
public string
# getCurrentBranchName( )

Gets name of current branch git branch + magic

Gets name of current branch git branch + magic

Returns

string

Throws

CzProject\GitPhp\GitException
public string[]|null
# getBranches( )

Returns list of all (local & remote) branches in repo.

Returns list of all (local & remote) branches in repo.

Returns

string[]|null
NULL => no branches

Throws

CzProject\GitPhp\GitException
public string[]|null
# getRemoteBranches( )

Returns list of remote branches in repo.

Returns list of remote branches in repo.

Returns

string[]|null
NULL => no branches

Throws

CzProject\GitPhp\GitException
public string[]|null
# getLocalBranches( )

Returns list of local branches in repo.

Returns list of local branches in repo.

Returns

string[]|null
NULL => no branches

Throws

CzProject\GitPhp\GitException
public static
# checkout( string $name )

Checkout branch. git checkout <branch>

Checkout branch. git checkout <branch>

Parameters

$name

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# removeFile( string|string[] $file )

Removes file(s). git rm <file>

Removes file(s). git rm <file>

Parameters

$file

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# addFile( string|string[] $file )

Adds file(s). git add <file>

Adds file(s). git add <file>

Parameters

$file

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# addAllChanges( )

Adds all created, modified & removed files. git add --all

Adds all created, modified & removed files. git add --all

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# renameFile( string|string[] $file, string|null $to = NULL )

Renames file(s). git mv <file>

Renames file(s). git mv <file>

Parameters

$file
array('from' => 'to', ...) || (from, to)
$to

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# commit( string $message, string[] $params = NULL )

Commits changes git commit <params> -m <message>

Commits changes git commit <params> -m <message>

Parameters

$message
$params
=> value

Returns

static

Throws

CzProject\GitPhp\GitException
public string|null
# getLastCommitId( )

Returns last commit ID on current branch git log --pretty=format:"%H" -n 1

Returns last commit ID on current branch git log --pretty=format:"%H" -n 1

Returns

string|null

Throws

CzProject\GitPhp\GitException
public boolean
# hasChanges( )

Exists changes? git status + magic

Exists changes? git status + magic

Returns

boolean

Throws

CzProject\GitPhp\GitException
public
# isChanges( )

Deprecated

Throws

CzProject\GitPhp\GitException
public static
# pull( string|null $remote = NULL, array $params = NULL )

Pull changes from a remote

Pull changes from a remote

Parameters

$remote
$params

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# push( string|null $remote = NULL, array $params = NULL )

Push changes to a remote

Push changes to a remote

Parameters

$remote
$params

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# fetch( string|null $remote = NULL, array $params = NULL )

Run fetch command to get latest branches

Run fetch command to get latest branches

Parameters

$remote
$params

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# addRemote( string $name, string $url, array $params = NULL )

Adds new remote repository

Adds new remote repository

Parameters

$name
$url
$params

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# renameRemote( string $oldName, string $newName )

Renames remote repository

Renames remote repository

Parameters

$oldName
$newName

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# removeRemote( string $name )

Removes remote repository

Removes remote repository

Parameters

$name

Returns

static

Throws

CzProject\GitPhp\GitException
public static
# setRemoteUrl( string $name, string $url, array $params = NULL )

Changes remote repository URL

Changes remote repository URL

Parameters

$name
$url
$params

Returns

static

Throws

CzProject\GitPhp\GitException
public string[]
# execute( string|string[] $cmd )

Parameters

$cmd

Returns

string[]
returns output

Throws

CzProject\GitPhp\GitException
protected static
# begin( )

Returns

static
protected static
# end( )

Returns

static
protected string[]|null
# extractFromCommand( string $cmd, callable|null $filter = NULL )

Parameters

$cmd
$filter

Returns

string[]|null

Throws

CzProject\GitPhp\GitException
protected static
# run( string|array $cmd )

Runs command.

Runs command.

Parameters

$cmd

Returns

static

Throws

CzProject\GitPhp\GitException
protected static
# processCommand( array $args )
public static static
# init( string $directory, array $params = NULL )

Init repo in directory

Init repo in directory

Parameters

$directory
$params

Returns

static

Throws

CzProject\GitPhp\GitException
public static static
# cloneRepository( string $url, string|null $directory = NULL, array $params = NULL )

Clones GIT repository from $url into $directory

Clones GIT repository from $url into $directory

Parameters

$url
$directory
$params

Returns

static

Throws

CzProject\GitPhp\GitException
public static boolean
# isRemoteUrlReadable( string $url, array $refs = NULL )

Parameters

$url
$refs

Returns

boolean
Properties summary
protected string $repository
#
protected string|null $cwd

@internal

@internal

#
czproject/git-php version-4.x API documentation API documentation generated by ApiGen