Copied!

Administration class for Git repositories.

CloneableInstantiable
Methods
public static cloneBranchTo( $path, $url, $branch, $bare = true, $options = [])
 

Clone a repository branch to a local path.

  • param string $path indicates where to clone repository
  • param string $url url of repository to clone
  • param string $branch branch to clone
  • param bool $bare indicates if repository should be bare or have a working copy
  • param array $options options for Repository creation
  • return \Repository
public static cloneRepository( $path, $url, array $args = [], array $options = [])
 

Internal method to launch effective git clone command.

  • param string $path indicates where to clone repository
  • param string $url url of repository to clone
  • param array $args arguments to be added to the command-line
  • param array $options options for Repository creation
  • return \Repository
public static cloneTo( $path, $url, $bare = true, array $options = [])
 

Clone a repository to a local path.

  • param string $path indicates where to clone repository
  • param string $url url of repository to clone
  • param bool $bare indicates if repository should be bare or have a working copy
  • param array $options options for Repository creation
  • return \Repository
public static init( $path, $bare = true, array $options = [])
 

Initializes a repository and returns the instance.

  • param string $path path to the repository
  • param bool $bare indicate to create a bare repository
  • param array $options options for Repository creation
  • throws \RuntimeException Directory exists or not writable (only if debug=true)
  • return \Repository
public static isValidRepository( $url, array $options = [])
 

Checks the validity of a git repository url without cloning it.

This will use the ls-remote command of git against the given url. Usually, this command returns 0 when successful, and 128 when the repository is not found.

  • param string $url url of repository to check
  • param array $options options for Repository creation
  • return bool true if url is valid
public static isValidRepositoryAndBranch( $url, $branchName, array $options = [])
 

Checks the validity of a git repository url without cloning it and check if a certain branch exists in that repository.

This will use the ls-remote command of git against the given url. Usually, this command returns 0 when successful, and 128 when the repository is not found.

  • param string $url url of repository to check
  • param string $branchName name of branch to check
  • param array $options options for Repository creation
  • return bool true if url is valid and branch exists
public static mirrorTo( $path, $url, array $options = [])
 

Mirrors a repository (fetch all revisions, not only branches).

  • param string $path indicates where to clone repository
  • param string $url url of repository to clone
  • param array $options options for Repository creation
  • return \Repository
Methods
private static getProcess( $command, array $args = [], array $options = [])
 

This internal method is used to create a process object.

Methods
public static cloneBranchTo( $path, $url, $branch, $bare = true, $options = [])
 

Clone a repository branch to a local path.

  • param string $path indicates where to clone repository
  • param string $url url of repository to clone
  • param string $branch branch to clone
  • param bool $bare indicates if repository should be bare or have a working copy
  • param array $options options for Repository creation
  • return \Repository
public static cloneRepository( $path, $url, array $args = [], array $options = [])
 

Internal method to launch effective git clone command.

  • param string $path indicates where to clone repository
  • param string $url url of repository to clone
  • param array $args arguments to be added to the command-line
  • param array $options options for Repository creation
  • return \Repository
public static cloneTo( $path, $url, $bare = true, array $options = [])
 

Clone a repository to a local path.

  • param string $path indicates where to clone repository
  • param string $url url of repository to clone
  • param bool $bare indicates if repository should be bare or have a working copy
  • param array $options options for Repository creation
  • return \Repository
private static getProcess( $command, array $args = [], array $options = [])
 

This internal method is used to create a process object.

public static init( $path, $bare = true, array $options = [])
 

Initializes a repository and returns the instance.

  • param string $path path to the repository
  • param bool $bare indicate to create a bare repository
  • param array $options options for Repository creation
  • throws \RuntimeException Directory exists or not writable (only if debug=true)
  • return \Repository
public static isValidRepository( $url, array $options = [])
 

Checks the validity of a git repository url without cloning it.

This will use the ls-remote command of git against the given url. Usually, this command returns 0 when successful, and 128 when the repository is not found.

  • param string $url url of repository to check
  • param array $options options for Repository creation
  • return bool true if url is valid
public static isValidRepositoryAndBranch( $url, $branchName, array $options = [])
 

Checks the validity of a git repository url without cloning it and check if a certain branch exists in that repository.

This will use the ls-remote command of git against the given url. Usually, this command returns 0 when successful, and 128 when the repository is not found.

  • param string $url url of repository to check
  • param string $branchName name of branch to check
  • param array $options options for Repository creation
  • return bool true if url is valid and branch exists
public static mirrorTo( $path, $url, array $options = [])
 

Mirrors a repository (fetch all revisions, not only branches).

  • param string $path indicates where to clone repository
  • param string $url url of repository to clone
  • param array $options options for Repository creation
  • return \Repository
© 2025 Bruce Wells