npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

git-trim

v0.2.1

Published

Quickly remove merged, pruned, untracked, or stale branches within a repository.

Downloads

30

Readme

git trim

A command to quickly remove merged, pruned, untracked, or stale branches within a repository.

Usage

git trim
git trim --pruned
git trim -p
    # Removes local branches where its remote branch no longer exists

git trim --merged
git trim -m
   # Removes local branches already merged into the current branch

git trim --stale
git trim -s
   # Removes local branches without commits in the last 3 months

git trim --untracked
git trim -u
    # Removes local branches not tracking a remote branch

git trim --reset[=remote]
    # Removes all local branches except those existing on remote which defaults to "origin" (requires confirmation)

git trim --all
    # Removes all local branches except the current branch (requires confirmation)

Of course, you may combine these options where appropriate. For example, git trim --merged --stale, would remove both local branches which have been merged with the current branch or are stale.

There are two additional options which may also be combined with the options above: --tracked and --remote.

When the --tracked (or -t) option is used, the remote tracking branch is also removed. For example, git trim --merged --tracked will remove local branches merged into the current branch, and remove the remote branch it's tracking (if any).

When the --remote (or -r) option is used, git trim will remove remote branches instead of local branches. For example, git trim --stale --remote will remove remote branches without commits in the last 3 months (stale local branches will not be removed).

Finally, you may also append the --dry-run option to any git-trim command to simply list the branches which would be deleted instead of actually removing them.

Installation

Basic install

The preferred installation method is to simply save the git-trim script somewhere included in your path. For example, copy git-trim into an existing included path like /usr/local/bin, or add the parent directory to your PATH environment.

Install via NPM

npm install --global git-trim

Install via ZSH

Oh-My-Zsh

  1. Run: git clone https://github.com/jasonmccreary/git-trim.git $ZSH_CUSTOM/plugins/git-trim
  2. Add git-trim to your plugin list: edit ~/.zshrc and change plugins=(...) to plugins=(... git-trim)

Updating

Once installed, the easiest way to update is to overwrite your local copy with the latest contents of the git-trim script.

Updating via NPM

npm update --global git-trim

Updating via ZSH

Oh-My-Zsh

cd $ZSH_CUSTOM/plugins/git-trim
git fetch
git pull

Configuration

By default, git trim will never remove the current branch. However, depending on your branching strategy, you may have additional branches you never want to remove. For example, a dev or staging branch.

If so, you may set a gt.exclude option to your Git configuration, either locally or globally, with a space delimited string of any additional branches you want to exclude from removal.

git config gt.exclude "dev staging"
    # Always exclude the "dev" and "staging" branches from removal

Disclaimer

Some of the options in this command remove branches without warning. Once a branch is removed, it might not be recoverable. You are solely responsible when running this command.

Credits

There are thousands of commands and aliases for cleaning up branches sprinkled across the internet. I'll specifically link the commands and posts shared in this Twitter thread, another project for inspiring the name, and git-open which I used as a code reference.

Contributing

Feel free to open an issue or pull request to help contribute to the project. Currently the only code style requirement is an indentation of 2 spaces.

License

Copyright Jason McCreary. Licensed under MIT.