Download the PHP package phppkg/phpgit without Composer
On this page you can find all versions of the php package phppkg/phpgit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phppkg/phpgit
More information about phppkg/phpgit
Files in phppkg/phpgit
Package phpgit
Short Description A Git wrapper library for PHP 8.1+
License MIT
Homepage https://github/phppkg/phpgit.git
Informations about the package phpgit
PhpGit
中文说明
PhpGit - 💪 Git wrapper and feature extension library written in PHP.
The project is forked from https://github.com/kzykhys/PHPGit
Features
- Quick run git commands, eg:
clone,add,commit,merge
- Git repo info fetch:
status
branch
remote
- Generate changelog by git log
Installation
Requirements
- PHP 8.1+
- Git
Method 1: directly composer require
Method 2: update composer.json
Update your composer.json and run composer update
Basic Usage
Git Info
Output:
Changelog
Provide quick generate formatted changelog.
Formatter
SimpleFormatter
MarkdownFormatter
GithubReleaseFormatter
Filter
KeywordFilter
KeywordsFilter
MsgLenFilter
WordsLenFilter
Example
Run example php bin/chlog.php
will see:
API
Git commands
- git add
- $git->add(string|array|\Traversable $file, array $options = [])
- git archive
- $git->archive(string $file, string $tree = null, string|array|\Traversable $path = null, array $options = [])
- git branch
- $git->branch(array $options = [])
- $git->branch->create(string $branch, string $startPoint = null, array $options = [])
- $git->branch->move(string $branch, string $newBranch, array $options = [])
- $git->branch->delete(string $branch, array $options = [])
- git cat-file
- $git->cat->blob(string $object)
- $git->cat->type(string $object)
- $git->cat->size(string $object)
- git checkout
- $git->checkout(string $branch, array $options = [])
- $git->checkout->create(string $branch, string $startPoint = null, array $options = [])
- $git->checkout->orphan(string $branch, string $startPoint = null, array $options = [])
- git clone
- $git->clone(string $repository, string $path = null, array $options = [])
- git commit
- $git->commit(string $message, array $options = [])
- git config
- $git->config(array $options = [])
- $git->config->set(string $name, string $value, array $options = [])
- $git->config->add(string $name, string $value, array $options = [])
- git describe
- $git->describe(string $committish = null, array $options = [])
- $git->describe->tags(string $committish = null, array $options = [])
- git fetch
- $git->fetch(string $repository, string $refspec = null, array $options = [])
- $git->fetch->all(array $options = [])
- git init
- $git->init(string $path, array $options = [])
- git log
- $git->log(string $revRange = '', string $path = null, array $options = [])
- git merge
- $git->merge(string|array|\Traversable $commit, string $message = null, array $options = [])
- $git->merge->abort()
- git mv
- $git->mv(string|array|\Iterator $source, string $destination, array $options = [])
- git pull
- $git->pull(string $repository = null, string $refspec = null, array $options = [])
- git push
- $git->push(string $repository = null, string $refspec = null, array $options = [])
- git rebase
- $git->rebase(string $upstream = null, string $branch = null, array $options = [])
- $git->rebase->continues()
- $git->rebase->abort()
- $git->rebase->skip()
- git remote
- $git->remote()
- $git->remote->add(string $name, string $url, array $options = [])
- $git->remote->rename(string $name, string $newName)
- $git->remote->rm(string $name)
- $git->remote->show(string $name)
- $git->remote->prune(string $name = null)
- $git->remote->head(string $name, string $branch = null)
- $git->remote->head->set(string $name, string $branch)
- $git->remote->head->delete(string $name)
- $git->remote->head->remote(string $name)
- $git->remote->branches(string $name, array $branches)
- $git->remote->branches->set(string $name, array $branches)
- $git->remote->branches->add(string $name, array $branches)
- $git->remote->url(string $name, string $newUrl, string $oldUrl = null, array $options = [])
- $git->remote->url->set(string $name, string $newUrl, string $oldUrl = null, array $options = [])
- $git->remote->url->add(string $name, string $newUrl, array $options = [])
- $git->remote->url->delete(string $name, string $url, array $options = [])
- git reset
- $git->reset(string|array|\Traversable $paths, string $commit = null)
- $git->reset->soft(string $commit = null)
- $git->reset->mixed(string $commit = null)
- $git->reset->hard(string $commit = null)
- $git->reset->merge(string $commit = null)
- $git->reset->keep(string $commit = null)
- $git->reset->mode(string $mode, string $commit = null)
- git rm
- $git->rm(string|array|\Traversable $file, array $options = [])
- $git->rm->cached(string|array|\Traversable $file, array $options = [])
- git shortlog
- $git->shortlog(string|array|\Traversable $commits = HEAD)
- $git->shortlog->summary(string $commits = HEAD)
- git show
- $git->show(string $object, array $options = [])
- git stash
- $git->stash()
- $git->stash->save(string $message = null, array $options = [])
- $git->stash->lists(array $options = [])
- $git->stash->show(string $stash = null)
- $git->stash->drop(string $stash = null)
- $git->stash->pop(string $stash = null, array $options = [])
- $git->stash->apply(string $stash = null, array $options = [])
- $git->stash->branch(string $name, string $stash = null)
- $git->stash->clear()
- $git->stash->create()
- git status
- $git->status(array $options = [])
- git tag
- $git->tag()
- $git->tag->create(string $tag, string $commit = null, array $options = [])
- $git->tag->delete(string|array|\Traversable $tag)
- $git->tag->verify(string|array|\Traversable $tag)
-
git ls-tree
- $git->tree(string $branch = master, string $path = '')
-
git add
Add file contents to the index
Options
- force (boolean) Allow adding otherwise ignored files
-
ignore-errors (boolean) Do not abort the operation
-
git archive
$git->archive(string $file, string $tree = null, string|array|\Traversable $path = null, array $options = [])
Create an archive of files from a named tree
Options
- format (boolean) Format of the resulting archive: tar or zip
-
prefix (boolean) Prepend prefix/ to each filename in the archive
-
git branch
$git->branch(array $options = [])
Returns an array of both remote-tracking branches and local branches
Output Example
Options
- all (boolean) List both remote-tracking branches and local branches
- remotes (boolean) List the remote-tracking branches
$git->branch->create(string $branch, string $startPoint = null, array $options = [])
Creates a new branch head named $branch which points to the current HEAD, or $startPoint if given
Options
- force (boolean) Reset $branch to $startPoint if $branch exists already
$git->branch->move(string $branch, string $newBranch, array $options = [])
Move/rename a branch and the corresponding reflog
Options
- force (boolean) Move/rename a branch even if the new branch name already exists
$git->branch->delete(string $branch, array $options = [])
Delete a branch
The branch must be fully merged in its upstream branch, or in HEAD if no upstream was set with --track or --set-upstream.
Options
-
force (boolean) Delete a branch irrespective of its merged status
-
git cat-file
$git->cat->blob(string $object)
Returns the contents of blob object
$git->cat->type(string $object)
Returns the object type identified by $object
$git->cat->size(string $object)
Returns the object size identified by $object
git checkout
$git->checkout(string $branch, array $options = [])
Switches branches by updating the index, working tree, and HEAD to reflect the specified branch or commit
Options
- force (boolean) Proceed even if the index or the working tree differs from HEAD
- merge (boolean) Merges local modification
$git->checkout->create(string $branch, string $startPoint = null, array $options = [])
Create a new branch and checkout
Options
- force (boolean) Proceed even if the index or the working tree differs from HEAD
$git->checkout->orphan(string $branch, string $startPoint = null, array $options = [])
Create a new orphan branch, named
Options
-
force (boolean) Proceed even if the index or the working tree differs from HEAD
-
git clone
$git->clone(string $repository, string $path = null, array $options = [])
Clone a repository into a new directory
Options
- shared (boolean) Starts out without any object of its own
-
bare (boolean) Make a bare GIT repository
-
git commit
$git->commit(string $message, array $options = [])
Record changes to the repository
Options
- all (boolean) Stage files that have been modified and deleted
- reuse-message (string) Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit
- squash (string) Construct a commit message for use with rebase --autosquash
- author (string) Override the commit author
- date (string) Override the author date used in the commit
- cleanup (string) Can be one of verbatim, whitespace, strip, and default
-
amend (boolean) Used to amend the tip of the current branch
-
git config
$git->config(array $options = [])
Returns all variables set in config file
Options
- global (boolean) Read or write configuration options for the current user
- system (boolean) Read or write configuration options for all users on the current machine
$git->config->set(string $name, string $value, array $options = [])
Set an option
Options
- global (boolean) Read or write configuration options for the current user
- system (boolean) Read or write configuration options for all users on the current machine
$git->config->add(string $name, string $value, array $options = [])
Adds a new line to the option without altering any existing values
Options
- global (boolean) Read or write configuration options for the current user
-
system (boolean) Read or write configuration options for all users on the current machine
-
git describe
$git->describe(string $committish = null, array $options = [])
Returns the most recent tag that is reachable from a commit
Output Example
Options
- all (boolean) Enables matching any known branch, remote-tracking branch, or lightweight tag
- tags (boolean) Enables matching a lightweight (non-annotated) tag
- always (boolean) Show uniquely abbreviated commit object as fallback
$git->describe->tags(string $committish = null, array $options = [])
Equivalent to $git->describe($committish, ['tags' => true]);
git fetch
$git->fetch(string $repository, string $refspec = null, array $options = [])
Fetches named heads or tags from one or more other repositories, along with the objects necessary to complete them
Options
- append (boolean) Append ref names and object names of fetched refs to the existing contents of .git/FETCH_HEAD
- keep (boolean) Keep downloaded pack
- prune (boolean) After fetching, remove any remote-tracking branches which no longer exist on the remote
$git->fetch->all(array $options = [])
Fetch all remotes
Options
- append (boolean) Append ref names and object names of fetched refs to the existing contents of .git/FETCH_HEAD
- keep (boolean) Keep downloaded pack
-
prune (boolean) After fetching, remove any remote-tracking branches which no longer exist on the remote
-
git init
$git->init(string $path, array $options = [])
Create an empty git repository or reinitialize an existing one
Options
- shared (boolean) Specify that the git repository is to be shared amongst several users
-
bare (boolean) Create a bare repository
-
git log
$git->log(string $revRange = '', string $path = null, array $options = [])
Returns the commit logs
Output Example
Options
- limit (integer) Limits the number of commits to show
-
skip (integer) Skip number commits before starting to show the commit output
-
git merge
$git->merge(string|array|\Traversable $commit, string $message = null, array $options = [])
Incorporates changes from the named commits into the current branch
Options
- no-ff (boolean) Do not generate a merge commit if the merge resolved as a fast-forward, only update the branch pointer
- rerere-autoupdate (boolean) Allow the rerere mechanism to update the index with the result of auto-conflict resolution if possible
- squash (boolean) Allows you to create a single commit on top of the current branch whose effect is the same as merging another branch
- strategy (string) Use the given merge strategy
- strategy-option (string) Pass merge strategy specific option through to the merge strategy
$git->merge->abort()
Abort the merge process and try to reconstruct the pre-merge state
git mv
$git->mv(string|array|\Iterator $source, string $destination, array $options = [])
Move or rename a file, a directory, or a symlink
Options
-
force (boolean) Force renaming or moving of a file even if the target exists
-
git pull
$git->pull(string $repository = null, string $refspec = null, array $options = [])
Fetch from and merge with another repository or a local branch
git push
$git->push(string $repository = null, string $refspec = null, array $options = [])
Update remote refs along with associated objects
git rebase
$git->rebase(string $upstream = null, string $branch = null, array $options = [])
Forward-port local commits to the updated upstream head
Options
- onto (string) Starting point at which to create the new commits
- no-verify (boolean) Bypasses the pre-rebase hook
- force-rebase (boolean) Force the rebase even if the current branch is a descendant of the commit you are rebasing onto
$git->rebase->continues()
Restart the rebasing process after having resolved a merge conflict
$git->rebase->abort()
Abort the rebase operation and reset HEAD to the original branch
$git->rebase->skip()
Restart the rebasing process by skipping the current patch
git remote
$git->remote()
Returns an array of existing remotes
Output Example
$git->remote->add(string $name, string $url, array $options = [])
Adds a remote named $name for the repository at $url
Options
- tags (boolean) With this option,
git fetch <name>
imports every tag from the remote repository - no-tags (boolean) With this option,
git fetch <name>
does not import tags from the remote repository
$git->remote->rename(string $name, string $newName)
Rename the remote named $name to $newName
$git->remote->rm(string $name)
Remove the remote named $name
$git->remote->show(string $name)
Gives some information about the remote $name
Output Example
$git->remote->prune(string $name = null)
Deletes all stale remote-tracking branches under $name
$git->remote->head(string $name, string $branch = null)
Alias of set()
$git->remote->head->set(string $name, string $branch)
Sets the default branch for the named remote
$git->remote->head->delete(string $name)
Deletes the default branch for the named remote
$git->remote->head->remote(string $name)
Determine the default branch by querying remote
$git->remote->branches(string $name, array $branches)
Alias of set()
$git->remote->branches->set(string $name, array $branches)
Changes the list of branches tracked by the named remote
$git->remote->branches->add(string $name, array $branches)
Adds to the list of branches tracked by the named remote
$git->remote->url(string $name, string $newUrl, string $oldUrl = null, array $options = [])
Alias of set()
Options
- push (boolean) Push URLs are manipulated instead of fetch URLs
$git->remote->url->set(string $name, string $newUrl, string $oldUrl = null, array $options = [])
Sets the URL remote to $newUrl
Options
- push (boolean) Push URLs are manipulated instead of fetch URLs
$git->remote->url->add(string $name, string $newUrl, array $options = [])
Adds new URL to remote
Options
- push (boolean) Push URLs are manipulated instead of fetch URLs
$git->remote->url->delete(string $name, string $url, array $options = [])
Deletes all URLs matching regex $url
Options
-
push (boolean) Push URLs are manipulated instead of fetch URLs
-
git reset
$git->reset(string|array|\Traversable $paths, string $commit = null)
Resets the index entries for all $paths to their state at $commit
$git->reset->soft(string $commit = null)
Resets the current branch head to $commit
Does not touch the index file nor the working tree at all (but resets the head to $commit, just like all modes do). This leaves all your changed files "Changes to be committed", as git status would put it.
$git->reset->mixed(string $commit = null)
Resets the current branch head to $commit
Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.
$git->reset->hard(string $commit = null)
Resets the current branch head to $commit
Resets the index and working tree. Any changes to tracked files in the working tree since $commit are discarded
$git->reset->merge(string $commit = null)
Resets the current branch head to $commit
Resets the index and updates the files in the working tree that are different between $commit and HEAD, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added). If a file that is different between $commit and the index has unstaged changes, reset is aborted
$git->reset->keep(string $commit = null)
Resets the current branch head to $commit
Resets index entries and updates files in the working tree that are different between $commit and HEAD. If a file that is different between $commit and HEAD has local changes, reset is aborted.
$git->reset->mode(string $mode, string $commit = null)
Resets the current branch head to $commit
Possibly updates the index (resetting it to the tree of $commit) and the working tree depending on $mode
git rm
$git->rm(string|array|\Traversable $file, array $options = [])
Remove files from the working tree and from the index
Options
- force (boolean) Override the up-to-date check
- cached (boolean) Unstage and remove paths only from the index
- recursive (boolean) Allow recursive removal when a leading directory name is given
$git->rm->cached(string|array|\Traversable $file, array $options = [])
Equivalent to $git->rm($file, ['cached' => true]);
Options
- force (boolean) Override the up-to-date check
-
recursive (boolean) Allow recursive removal when a leading directory name is given
-
git shortlog
$git->shortlog(string|array|\Traversable $commits = HEAD)
Summarize 'git log' output
Output Example
$git->shortlog->summary(string $commits = HEAD)
Suppress commit description and provide a commit count summary only
Output Example
git show
$git->show(string $object, array $options = [])
Shows one or more objects (blobs, trees, tags and commits)
Options
- format (string) Pretty-print the contents of the commit logs in a given format, where
can be one of oneline, short, medium, full, fuller, email, raw and format: -
abbrev-commit (boolean) Instead of showing the full 40-byte hexadecimal commit object name, show only a partial prefix
-
git stash
$git->stash()
Save your local modifications to a new stash, and run git reset --hard to revert them
$git->stash->save(string $message = null, array $options = [])
Save your local modifications to a new stash, and run git reset --hard to revert them.
$git->stash->lists(array $options = [])
Returns the stashes that you currently have
Output Example
$git->stash->show(string $stash = null)
Show the changes recorded in the stash as a diff between the stashed state and its original parent
Output Example
$git->stash->drop(string $stash = null)
Remove a single stashed state from the stash list
$git->stash->pop(string $stash = null, array $options = [])
Remove a single stashed state from the stash list and apply it on top of the current working tree state
$git->stash->apply(string $stash = null, array $options = [])
Like pop, but do not remove the state from the stash list
$git->stash->branch(string $name, string $stash = null)
Creates and checks out a new branch named
$git->stash->clear()
Remove all the stashed states
$git->stash->create()
Create a stash (which is a regular commit object) and return its object name, without storing it anywhere in the ref namespace
Output Example
git status
$git->status(array $options = [])
Returns the working tree status
Constants
- StatusCommand::UNMODIFIED [=' '] unmodified
- StatusCommand::MODIFIED [='M'] modified
- StatusCommand::ADDED [='A'] added
- StatusCommand::DELETED [='D'] deleted
- StatusCommand::RENAMED [='R'] renamed
- StatusCommand::COPIED [='C'] copied
- StatusCommand::UPDATED_BUT_UNMERGED [='U'] updated but unmerged
- StatusCommand::UNTRACKED [='?'] untracked
- StatusCommand::IGNORED [='!'] ignored
Output Example
Options
-
ignored (boolean) Show ignored files as well
-
git tag
$git->tag()
Returns an array of tags
Output Example
$git->tag->create(string $tag, string $commit = null, array $options = [])
Creates a tag object
Options
- annotate (boolean) Make an unsigned, annotated tag object
- sign (boolean) Make a GPG-signed tag, using the default e-mail address’s key
- force (boolean) Replace an existing tag with the given name (instead of failing)
$git->tag->delete(string|array|\Traversable $tag)
Delete existing tags with the given names
$git->tag->verify(string|array|\Traversable $tag)
Verify the gpg signature of the given tag names
git ls-tree
$git->tree(string $branch = master, string $path = '')
Returns the contents of a tree object
Output Example
License
The MIT License
Author
Developed by Kazuyuki Hayashi (@kzykhys), Maintained by @inhere
All versions of phpgit with dependencies
toolkit/cli-utils Version ~2.0
toolkit/stdlib Version ~2.0
symfony/process Version ~6.0 || ~7.0
symfony/options-resolver Version ~6.0 || ~7.0