PHPackages                             sweetchuck/git - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. sweetchuck/git

ActiveLibrary

sweetchuck/git
==============

Git related helpers classes.

1.x-dev(4mo ago)10[2 PRs](https://github.com/Sweetchuck/git/pulls)1GPL-2.0-or-laterPHPPHP &gt;=8.4CI passing

Since Jan 18Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Sweetchuck/git)[ Packagist](https://packagist.org/packages/sweetchuck/git)[ RSS](/packages/sweetchuck-git/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelogDependencies (12)Versions (3)Used By (1)

Git-related helper classes
==========================

[](#git-related-helper-classes)

[![CI](https://github.com/Sweetchuck/git/actions/workflows/ci.yml/badge.svg?branch=1.x)](https://github.com/Sweetchuck/git/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/0be7ea41cd8ee14d78373b37df21aa4c24108127cde5da8538310ac95bf519d8/68747470733a2f2f636f6465636f762e696f2f67682f5377656574636875636b2f6769742f67726170682f62616467652e7376673f746f6b656e3d5052534e304d494e4248)](https://codecov.io/gh/Sweetchuck/git)

Commands
--------

[](#commands)

**Why use this package instead of \\exec()?**

Using these commands instead of directly calling `\exec()` offers several advantages:

1. **Structured data handling**
    Results are parsed into PHP arrays and objects, making them easier to work with than raw command output.

**Supported commands**

- start a working area
    - ✔ `git init`
    - ✔ `git clone`
- work on the current change
    - ✔ `git add`
    - ✔ `git mv`
    - ✔ `git restore`
    - ✔ `git rm`
    - 🛠 `git apply -- `
    - 🛠 `git apply --stat`
    - 🛠 `git apply --numstat`
    - 🛠 `git apply --sumary`
    - 🛠 `git apply --check`
    - 🛠 `git stash`
        - 🛠 `git stash list`
        - 🛠 `git stash show`
        - 🛠 `git stash drop`
        - 🛠 `git stash pop`
        - 🛠 `git stash apply`
        - 🛠 `git stash branch`
        - 🛠 `git stash push`
        - 🛠 `git stash save`
        - 🛠 `git stash clear`
        - 🛠 `git stash create`
        - 🛠 `git stash store`
        - 🛠 `git stash export`
        - 🛠 `git stash import`
- examine the history and state
    - 🛠 `git bisect`
    - 🛠 `git diff-tree --patch`
    - 🛠 `git diff-tree --stat`
    - 🛠 `git diff-tree --compact-summary`
    - 🛠 `git diff-tree --numstat`
    - 🛠 `git diff-tree --shortstat`
    - 🛠 `git diff-tree --dirstat`
    - 🛠 `git diff-tree --summary`
    - 🛠 `git diff-tree -S`
    - 🛠 `git diff-tree -G`
    - 🛠 `git diff`
    - ✔ `git diff --name-status --cached`
    - ✔ `git diff --name-status` (without `--cached`)
    - ✔ `git grep`
    - 🛠 `git log`
        - ✔ `git log --name-status` (src/Command/GetCommits.php)
        - 🛠 `git log --full-diff`
        - 🛠 `git log -L,:`
        - 🛠 `git log -L::`
    - 🛠 `git show`
        - ✔ `git show [ref]:` (src/Command/GetFileContent.php)
    - ✔ `git status`
    - ✔ `git ls-files`
    - ✔ `git ls-tree`
    - 🛠 `git ls-remote`
    - ✔ `git check-ignore`
    - ✔ `git check-attr`
- grow, mark and tweak your common history
    - 🛠 `git backfill`
    - ✔ `git branch CREATE`
    - ✔ `git branch --list --verbose`
    - ✔ `git branch --move`
    - ✔ `git branch --set-upstream-to`
    - ✔ `git branch --delete`
    - ✔ `git commit`
    - ✔ `git merge`
    - ✔ `git rebase`
    - ✔ `git reset`
    - 🛠 `git checkout`
    - ✔ `git symbolic-ref           ` UpsertSymbolicRef
    - ✔ `git symbolic-ref          ` ReadSymbolicRef
    - ✔ `git symbolic-ref --delete ` DeleteSymbolicRef
    - ✔ `git switch`
    - ✔ `git tag CREATE`
    - ✔ `git tag --list --verbose`
    - ✔ `git tag --delete`
- collaborate
    - 🛠 `git remote`
        - ✔ `git remote --verbose`
        - ✔ `git remote add`
        - ✔ `git remote rename`
        - ✔ `git remote remove`
        - ✔ `git remote update`
        - ✔ `git remote get-url` Fetch, Push
        - ✔ `git remote set-url` Set, Add, Delete
        - ✔ `git remote prune`
        - ✔ `git remote set-branches`
        - 🛠 `git remote set-head`
        - 🛠 `git remote show`
    - ✔ `git fetch`
    - ✔ `git pull`
    - ✔ `git push`
- config
    - ✔ `git config list`
    - ✔ `git config get`
    - ✔ `git config set`
    - ✔ `git config unset`
- other
    - ✔ `git --version`
    - ✔ `git --exec-path`
    - 🛠 and a lot of other commands

stdInput reader
---------------

[](#stdinput-reader)

### stdInput reader - Supported Git hooks

[](#stdinput-reader---supported-git-hooks)

- [post-receive](https://git-scm.com/docs/githooks#post-receive)
- [post-rewrite](https://git-scm.com/docs/githooks#_post_rewrite)
- [pre-push](https://git-scm.com/docs/githooks#_pre_push)
- [pre-receive](https://git-scm.com/docs/githooks#pre-receive)

### stdInput reader - Usage

[](#stdinput-reader---usage)

**.git/hooks/pre-receive**

```
#!/usr/bin/env php
