Skip to content

pswai/git-sweep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-sweep npm version

Git utility to clean up remote branches

Install

npm install -g git-sweep

Options

path

Type: String

Path to target git repository.

remote

Type: String

Default: origin

Target remote to clean up.

ignore

Type: String

Default: origin/master

Branches to be ignored. Must be specified in <remote>/<branch> format. Use comma to delimit multiple branches. This option will be merged with the configuration in .gitsweepignore.

preview

Type: Boolean

Default: false

Run git-sweep without actually deleting any branch. Useful for verifying the list of branches that will be deleted.

age

Type: String

Default: 1m

Minimum age for a branch to be considered for deletion. Format 1y2m3d means "older than 1 year 2 months and 3 days".

password

Type: Boolean

Example Usage

Delete remote branches that are older than 1 month except origin/master

git-sweep /path/to/repo

Delete older than 1 year, 2 month and 3 days

git-sweep /path/to/repo --age 1y2m3d

Delete except origin/master and origin/dev

git-sweep /path/to/repo --ignore origin/master,origin/dev

Delete from another remote

git-sweep /path/to/repo --remote fork

Dry run

git-sweep /path/to/repo --preview

Config file

A .gitsweepignore can be added to configure the ignore option. When used together with --ignore, their entries will be merged.

Authentication

git-sweep currently supports ssh-agent only.

Roadmap

  • Authentication methods
    • username/password
    • HTTPS
    • github 2FA
    • Manual ssh key files
  • Filters
    • Merged branch
    • Cutoff date (similar to age)
  • CLI help

License

MIT

Changelog

v0.4.0

  • Upgrade NodeGit to v0.24.0

v0.3.0

  • Upgrade NodeGit to v0.16.0

v0.2.0

  • Fix EOL issue in OS X
  • Changed path to be mandatory

v0.1.3

  • Fix missing auth callbacks when actual push

v0.1.2

  • Add support to authenticate using password
  • Add CLI help

v0.1.1

  • Add support to authenticate using ssh-agent

v0.1.0

  • First release