Giter Site home page Giter Site logo

git-spruce-php's Introduction

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 or play on words.

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

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

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

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

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

$ 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'.

git-spruce-php's People

Contributors

bencromwell avatar

Watchers

 avatar James Cloos avatar

git-spruce-php's Issues

PHP Fatal error after running git-spruce

After running the git-spruce command in my directory I was thrown the following error:

PHP Fatal error:  Uncaught Error: Class "Symfony\Component\Console\Application" not found in /Users/kaleshe/git-spruce/bin/git-spruce.php:14
Stack trace:
#0 {main}
  thrown in /Users/kaleshe/git-spruce/bin/git-spruce.php on line 14

Fatal error: Uncaught Error: Class "Symfony\Component\Console\Application" not found in /Users/kaleshe/git-spruce/bin/git-spruce.php:14
Stack trace:
#0 {main}
  thrown in /Users/kaleshe/git-spruce/bin/git-spruce.php on line 14

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.