Fork me on GitHub

Git.php

Documentation

CodeIgniter Version

If you are using the CI version, odds are you will be working with the Git class. After loading the library, eg.

$this->load->library('git');

the Git class included only has two methods. After that point, you will be working with same methods as the normal version, so you can read down through all of that, too.

Existing Repository

GitRepo $this->git->open ( string $repo_path )

This is an alias for GitRepo::__construct; see below.

Creating New Repository

GitRepo $this->git->create ( string $repo_path[, string $source ])

This is an alias for GitRepo::create_new; see below.

Standard Version

Creating/Opening Repositories

If you are using the standard version, you will probably always be working directly with the GitRepo class. The CI folks will also need to know this stuff, too, though.

GitRepo &GitRepo::create_new( string $repo_path[, string $source ])

This creates a new git repository in $repo_path and then returns an instance of GitRepo refering to it. Optionally, the second parameter sets the source directory of the files to use.

void GitRepo->__construct( string $repo_path[, bool $create_new = false ])

This opens an existing git repository in $repo_path. The second parameter decides if a new repository should be created if one doesn't already exist.

void GitRepo->set_repo_path( string $repo_path[, bool $create_new = false ])

This is exactly identical to the constructor except that you call it on an already existing GitRepo object.

Running Commands

You can run any git command using the run method, or you can use one of the handful of shortcut methods.

string GitRepo->run( string $command )
git add $files
string GitRepo->add([ string $files = '*' ])
git commit -av -m "$message"
string GitRepo->commit([ string $message = '' ])
git clone --local /your/repo $target
string GitRepo->clone_to( string $target )
git clone --local $source /your/repo
string GitRepo->clone_from( string $source )
git clone $source /your/repo
string GitRepo->clone_remote( string $source )
git clean ($dirs ? -d)
string GitRepo->clean([ bool $dirs = false ])
git branch $branch
string GitRepo->create_branch( string $branch )
git branch ($force ? -D : -d) $branch
string GitRepo->delete_branch( string $branch[, $force = false ])
git checkout $branch
string GitRepo->checkout( string $branch )