PHPackages                             cromwell/git-spruce - 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. [CLI &amp; Console](/categories/cli)
4. /
5. cromwell/git-spruce

ActiveLibrary[CLI &amp; Console](/categories/cli)

cromwell/git-spruce
===================

CLI for sprucing up your local git, cleans out branches that have been merged upstream.

0.2.0(4y ago)08[2 issues](https://github.com/bencromwell/git-spruce-php/issues)MITPHP

Since Nov 28Pushed 3y ago1 watchersCompare

[ Source](https://github.com/bencromwell/git-spruce-php)[ Packagist](https://packagist.org/packages/cromwell/git-spruce)[ RSS](/packages/cromwell-git-spruce/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (4)Used By (0)

git-spruce
==========

[](#git-spruce)

CLI for sprucing up your local git, cleans out branches that have been merged upstream. Spruce is a tree, this tool cleans your branches. It is a [pune](https://wiki.lspace.org/Pune) or play on words.

usage
-----

[](#usage)

```
Description:
  Removes branches that have been merged to the configured merge base branch

Usage:
  [options]

Options:
  -p, --prune           Run a git fetch -p
  -f, --force           Runs git branch -D on detected branches.
```

Clone the repo to wherever you want, and add an alias:

```
$ alias 'git-spruce'='php /path/to/git-spruce/bin/git-spruce.php'
```

It runs contextual to the current working directory and prompts for each branch to potentially remove.

options
-------

[](#options)

### prune

[](#prune)

The `-p` prune option runs `get fetch -p`.

This is important because otherwise you don't know what branches have been deleted upstream.

It's not enabled by default because it's slower as it contacts the remote.

### force

[](#force)

By default, `git-spruce` runs `git branch -d`.

If you've not updated your local merge base yet, you may need the force delete option to remove branches that are in fact merged upstream.

config
------

[](#config)

A global default config file, `config.yml`, lives alongside the installation.

This contains the following keys:

- `ignore_branches`: an array of branches to never remove. Defaults to develop, main and master.
- `merge_base`: the merge base we're checking again to check what's merged. In a usual git flow workflow this will be develop. The default here is 'main'.

For the merge\_base, 'main' and 'master' branches are treated as synonyms to handle the scenario where both conventions are in use.

You can override the config on a per repository basis by adding a `.git-spruce.yml` configuration file to each repo.

Perhaps you only merge to main on a particular repo, or some other branch. This is for that use case.

interactive
-----------

[](#interactive)

The deletion action is destructive, so it's interactive, prompting for confirmation for every deletion.

If you mess up you can probably recover a deleted branch from `git reflog`.

recovery
--------

[](#recovery)

```
$ git-spruce
Branch feature/foo is merged. Remove? y
Deleted branch feature/foo (was 19968853d).
```

```
$ git reflog | grep 19968853d
19968853d HEAD@{131}: commit: This is a test commit
```

```
$ git checkout 19968853d
Note: switching to '19968853d'.
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1732d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e9c29b364fc8b9934fb124303aaba7c7be7273c165954069b0af07b42b5781a2?d=identicon)[ben.cromwell](/maintainers/ben.cromwell)

---

Top Contributors

[![bencromwell](https://avatars.githubusercontent.com/u/683855?v=4)](https://github.com/bencromwell "bencromwell (20 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cromwell-git-spruce/health.svg)

```
[![Health](https://phpackages.com/badges/cromwell-git-spruce/health.svg)](https://phpackages.com/packages/cromwell-git-spruce)
```

###  Alternatives

[crunzphp/crunz

Schedule your tasks right from the code.

2292.0M6](/packages/crunzphp-crunz)[crazywhalecc/static-php-cli

Build single static PHP binary, with PHP project together, with popular extensions included.

1.8k13.9k](/packages/crazywhalecc-static-php-cli)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[phpcr/phpcr-shell

Shell for PHPCR

721.3M8](/packages/phpcr-phpcr-shell)[madewithlove/license-checker

CLI tool to verify allowed licenses for composer dependencies

54449.8k21](/packages/madewithlove-license-checker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
