Skip to content
forked from phpnode/YiiGit

A git wrapper for Yii, allows access to all git commands programatically

Notifications You must be signed in to change notification settings

danishsatkut/YiiGit

 
 

Repository files navigation

Introduction

A Yii wrapper for the git command line executable. Allows access to all git commands via a simple object oriented interface.

Usage examples

Add some files and folders to git

$repository = new AGitRepository;
$repository->path = "path/to/your/git/repo";
$repository->add("somefile.txt");
$repository->add("somedirectory");

Commit some files with git

$repository->commit("Added some files");

Checkout a new branch

$repository->checkout("some-new-branch", true);
echo $repository->activeBranch->name; // some-new-branch

Checkout an existing branch

$repository->checkout("some-new-branch");
echo $repository->activeBranch->name; // some-new-branch

List all branches

foreach($repository->branches as $branch) {
	echo $branch->name."\n";
}

List all the commits on the current branch

foreach($repository->activeBranch->commits as $commit) {
	echo $commit->authorName." at ".$commit->time."\n";
	echo $commit->message."\n";
	echo str_repeat("-",50)."\n";
}

List all the files affected by the latest commit

foreach($repository->activeBranch->latestCommit->files as $file) {
	echo $file."\n";
}

About

A git wrapper for Yii, allows access to all git commands programatically

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages