GitRepo
class GitRepo
Git Repository Interface Class
This class enables the creating, reading, and manipulation of a git repository
Properties
protected | $repo_path | ||
protected | $bare | ||
protected | $envopts |
Methods
Create a new git repository
Constructor
Set the repository's path
Get the path to the git repo directory (eg. the ".git" directory)
Tests if git is installed
Run a command in the git repository
Run a git command in the git repository
Runs a 'git status' call
Runs a git add
call
Runs a git rm
call
Runs a git commit
call
Runs a git clone
call to clone the current repository
into a different directory
Runs a git clone
call to clone a different repository
into the current repository
Runs a git clone
call to clone a remote repository
into the current repository
Runs a git clean
call
Runs a git branch
call
Runs a git branch -[d|D]
call
Runs a git branch
call
Lists remote branches (using git branch -r
).
Returns name of active branch
Runs a git checkout
call
Runs a git merge
call
Runs a git fetch on the current branch
Add a new tag on the current position
List all the available repository tags.
Push specific branch to a remote
Pull specific branch from remote
List log entries.
Sets the project description.
Gets the project description.
Sets custom environment options for calling Git
Details
at line 46
static GitRepo
create_new($repo_path, $source = null, $remote_source = false, $reference = null)
Create a new git repository
Accepts a creation path, and, optionally, a source path
at line 80
void
__construct($repo_path = null, $create_new = false, $_init = true)
Constructor
Accepts a repository path
at line 97
void
set_repo_path(string $repo_path, bool $create_new = false, bool $_init = true)
Set the repository's path
Accepts the repository path
at line 148
string
git_directory_path()
Get the path to the git repo directory (eg. the ".git" directory)
at line 158
bool
test_git()
Tests if git is installed
at line 185
protected string
run_command(string $command)
Run a command in the git repository
Accepts a shell command to run
at line 233
string
run(string $command)
Run a git command in the git repository
Accepts a git command to run
at line 246
string
status(bool $html = false)
Runs a 'git status' call
Accept a convert to HTML bool
at line 263
string
add(mixed $files = "*")
Runs a git add
call
Accepts a list of files to add
at line 280
string
rm(mixed $files = "*", Boolean $cached = false)
Runs a git rm
call
Accepts a list of files to remove
at line 298
string
commit(string $message = "", boolean $commit_all = true)
Runs a git commit
call
Accepts a commit message string
at line 313
string
clone_to(string $target)
Runs a git clone
call to clone the current repository
into a different directory
Accepts a target directory
at line 327
string
clone_from(string $source)
Runs a git clone
call to clone a different repository
into the current repository
Accepts a source directory
at line 342
string
clone_remote(string $source, string $reference)
Runs a git clone
call to clone a remote repository
into the current repository
Accepts a source url
at line 356
string
clean(bool $dirs = false, bool $force = false)
Runs a git clean
call
Accepts a remove directories flag
at line 369
string
create_branch(string $branch)
Runs a git branch
call
Accepts a name for the branch
at line 382
string
delete_branch($branch, $force = false)
Runs a git branch -[d|D]
call
Accepts a name for the branch
at line 393
array
list_branches(bool $keep_asterisk = false)
Runs a git branch
call
at line 415
array
list_remote_branches()
Lists remote branches (using git branch -r
).
Also strips out the HEAD reference (e.g. "origin/HEAD -> origin/master").
at line 433
string
active_branch(bool $keep_asterisk = false)
Returns name of active branch
at line 453
string
checkout(string $branch)
Runs a git checkout
call
Accepts a name for the branch
at line 467
string
merge(string $branch)
Runs a git merge
call
Accepts a name for the branch to be merged
at line 478
string
fetch()
Runs a git fetch on the current branch
at line 491
string
add_tag(string $tag, string $message = null)
Add a new tag on the current position
Accepts the name for the tag and the message
at line 507
array
list_tags(string $pattern = null)
List all the available repository tags.
Optionally, accept a shell wildcard pattern and return only tags matching it.
at line 528
string
push(string $remote, string $branch)
Push specific branch to a remote
Accepts the name of the remote and local branch
at line 541
string
pull(string $remote, string $branch)
Pull specific branch from remote
Accepts the name of the remote and local branch
at line 551
string
log(strgin $format = null)
List log entries.
at line 563
set_description(string $new)
Sets the project description.
at line 573
string
get_description()
Gets the project description.
at line 584
setenv(string $key, string $value)
Sets custom environment options for calling Git