1.0.3 • Published 1 year ago

clear-branches v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
1 year ago

clear-branches

Productive and easy way to clear your local git branches

Getting started

Overview

It's recommended for you who:

  • Usually struggle in clearing your local git branches.
  • Anyone that doesn't have the habit of deleting the branches constantly and gets crazy managing a lot of branches.
  • Prefer using a terminal rather than a Git GUI Client.

Motivation

I implemented this code once ago, as a tiny and ugly script only to help me to be more productive. And I realized that some colleagues were looking for something like this and I've published it to be available to anyone else to use and contribute.

Requirement

Recommended node version equal to or greater than v16

Quick start

You don't need to install it globally, if the idea is to use it sometimes, you can just execute it into your git project, so that you will execute the latest stable version.

$ npx clear-branches@latest

Or install it on your machine:

yarn:

$ yarn global add clear-branches

npm:

$ npm i -g clear-branches

output

Now clear-branches is executable anywhere you want, if you try into your project you will see the list of branches it will delete and a confirmation message:

$ clear-branches
  feat/component
  feat/feature
  fix/functions
? Are you sure you want to delete listed branches above? › (y/N)

Advanced options

Considering a project with these branches:

  feat/component
  feat/feature
  fix/functions
  main
  release

clear-branches --force=\,\

It force ignored branches by default to be considered to clear.

By default, clear-branches ignores these branches.

  main
  master
  release
  develop

*The current branch is ignored and is not possible to force delete it

Using clear-branches --force=<branch>[,<branch>], you will be able not to ignore any of these branches.

I.e.:

$ clear-branches --force=main
  feat/component
  feat/feature
  fix/functions
  main  # <-- now main is in the list to deleted
? Are you sure you want to delete listed branches above? › (y/N)

clear-branches --ignore=\,\

It ignores the branches you don't want to delete.

I.e.:

$ clear-branches --ignores=feat/component,feat/feature
  fix/functions
? Are you sure you want to delete listed branches above? › (y/N)

In this example, feat/component and feat/feature won't be deleted.

clear-branches --ignore-pattern=\

It ignores all branches that match a regex.

I.e.:

$ clear-branches --ignores=feat\/\\w+
  fix/functions
? Are you sure you want to delete listed branches above? › (y/N)

_As both feat/component and feat/feature match the feat\/\\w+ regex, they won't be deleted.

It's needed to escape if you need to use \, like \\w+

clear-branches -i, --interactive

With this option, you can select the branch you want to delete.

I.e.:

$ clear-branches -i --force=release,main
? Choose the branches you want to delete: ›
Instructions:
    ↑/↓: Highlight option
    ←/→/[space]: Toggle selection
    a: Toggle all
    enter/return: Complete answer
◉   feat/component
◉   feat/feature
◯   fix/functions
◯   release
◯   main

After pressing Enter:

$ clear-branches -i --force=release,main
✔ Choose the branches you want to delete: › feat/component, feat/feature
? Are you sure you want to delete listed branches above? › (y/N)

Contributing

Cloning and running

Testing

Architecture

Issues

To comfortable start contributing to this project, it is encouraged you go for this list of good start issues:

More labels

Contributors

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.0.1-rc9

1 year ago

1.0.3

1 year ago

1.0.1-rc7

1 year ago

0.0.8

1 year ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago