teppeis / git-delete-squashed

Delete branches that have been squashed and merged into master

Home Page:https://www.npmjs.com/package/@teppeis/git-delete-squashed

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@teppeis/git-delete-squashed (forked)

NPM version Node.js Version Support Dependency Status License

This is a tool that deletes all of your git branches that have been "squash-merged" into default branch (master or main).

This is useful if you work on a project that squashes branches into default branch. After your branch is squashed and merged, you can use this tool to clean up the local branch.

Guessing default branch (difference from original)

This fork supports not only master, but also main or other default branch names in the following order.

  1. If env DEFAULT_BRANCH is set, use it.
  2. If the repo has local branch master, use it.
  3. If the repo has local branch main, use it.
  4. Throws an error.

Usage

Node.js

You can also install the tool as a Node.js package from NPM. (The package code is in this repo.)

$ npx @teppeis/git-delete-squashed

Details

To determine if a branch is squash-merged, git-delete-squashed creates a temporary dangling squashed commit with git commit-tree. Then it uses git cherry to check if the squashed commit has already been applied to main. If so, it deletes the branch.

About

Delete branches that have been squashed and merged into master

https://www.npmjs.com/package/@teppeis/git-delete-squashed

License:MIT License


Languages

Language:JavaScript 100.0%