Search by

Git related helpers classes.

Package info

github.com/Sweetchuck/git

pkg:composer/sweetchuck/git

Statistics

Installs: 0

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 1

1.x-dev 2026-05-28 20:27 UTC

This package is auto-updated.

Last update: 2026-10-01 08:29:14 UTC


README

CI codecov

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 -- <paths>
    • 🛠 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<pattern>
    • 🛠 git diff-tree -G<pattern>
    • 🛠 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<start>,<end>:<file>
      • 🛠 git log -L:<funcname>:<file>
    • 🛠 git show
      • ✔ git show [ref]:<filePath> (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 <name> <ref> UpsertSymbolicRef
    • ✔ git symbolic-ref <name> ReadSymbolicRef
    • ✔ git symbolic-ref --delete <name> 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 - Supported Git hooks

stdInput reader - Usage

.git/hooks/pre-receive

#!/usr/bin/env php
<?php

use Sweetchuck\Git\StdInputReader\PreReceiveReader;

$reader = new PreReceiveReader(\STDIN);

foreach ($reader as $item) {
    echo 'Old value: ', $item->oldValue, \PHP_EOL;
    echo 'New value: ', $item->newValue, \PHP_EOL;
    echo 'Ref name:  ', $item->refName, \PHP_EOL;
    echo '-----------', \PHP_EOL;
}