Skip to content

Commit

Permalink
Readme: a few improved
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Pecha <[email protected]>
  • Loading branch information
janpecha committed Sep 18, 2013
1 parent 3baaf88 commit 7253444
Showing 1 changed file with 104 additions and 5 deletions.
109 changes: 104 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Git-PHP
============
=======

Library for work with Git repository in PHP.

Expand All @@ -9,12 +9,12 @@ Usage
``` php
<?php
// new repo object
$repo = new Cz\Git\GitRepository(__DIR__);
$repo = new Cz\Git\GitRepository('/path/to/repo');

// new file
$filename = __DIR__ . '/first.txt';
$filename = '/path/to/repo/first.txt';
file_put_contents($filename, "Lorem ipsum\ndolor\nsit amet");

// commit
$repo->addFile($filename);
$repo->commit('init commit');
Expand All @@ -23,6 +23,104 @@ Usage
[API documentation](http://api.iunas.cz/git-php/)


Initialization of empty repository
----------------------------------

``` php
<?php
$repo = GitRepository::init('/path/to/repo-directory');
```


Cloning of repository
---------------------

``` php
<?php
// Cloning of repository into subdirectory 'git-php' in current working directory
$repo = GitRepository::cloneRepository('https://github.com/czproject/git-php.git');

// Cloning of repository into own directory
$repo = GitRepository::cloneRepository('https://github.com/czproject/git-php.git', '/path/to/my/subdir');
```


Basic operations
----------------

``` php
<?php
$repo->isChanges();
$repo->commit('commit message');
$repo->merge('branch-name');
$repo->checkout('master');

$repo->getRepositoryPath();

// adds files into commit
$repo->addFile('file.txt');
$repo->addFile('file1.txt', 'file2.txt');
$repo->addFile(array('file3.txt', 'file4.txt'));

// renames files in repository
$repo->renameFile('old.txt', 'new.txt');
$repo->renameFile(array(
'old1.txt' => 'new1.txt',
'old2.txt' => 'new2.txt',
));

// removes files from repository
$repo->removeFile('file.txt');
$repo->removeFile('file1.txt', 'file2.txt');
$repo->removeFile(array('file3.txt', 'file4.txt'));
```



Manipulation with branches
--------------------------

``` php
<?php
// gets list of all repository branches (remotes & locals)
$repo->getBranches();

// gets list of all local branches
$repo->getLocalBranches();

// gets name of current branch
$repo->getCurrentBranchName();

// creates new branch
$repo->createBranch('new-branch');

// creates new branch and checkout
$repo->createBranch('patch-1', TRUE);

// removes branch
$repo->removeBranch('branch-name');
```


Manipulation with tags
--------------------------

``` php
<?php
// gets list of all repository tags
$repo->getTags();

// creates new tag
$repo->createTag('v1.0.0');

// renames tag
$repo->renameTag('old-tag', 'new-tag');

// removes tag
$repo->removeTag('tag-name');
```


Installation
------------

Expand All @@ -36,3 +134,4 @@ composer require czproject/git-php

License: [New BSD License](license.md)
<br>Author: Jan Pecha, http://janpecha.iunas.cz/

0 comments on commit 7253444

Please sign in to comment.