Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
bin
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

git-snip

Build Status Code Climate Test Coverage

Clean obsolete branches on your git repository safely.

When a branch has been merged remotely, your local branch is not automatically deleted and will build up, making it harder to find your relevant branches.

This gem aims to fix that by doing using git cherry to find local branches which have been merged and delete them.

asciicast

Installation

Install using RubyGems:

$ gem install git_snip

You can also this line to your application's Gemfile:

gem 'git_snip', require: false

And then execute:

$ bundle

Usage

You can list the available options from command line:

$ git snip help
Usage:
  git-snip
Options:
  -f, [--force]                    # Will refuse to run unless given -f or -n.
  -n, [--dry-run], [--no-dry-run]  # Show branches which would be deleted.
      [--repo=<path>]              # Path to git repository.
                                   # Default: .
      [--target=<branch>]          # Branch to compare equivalence against.
                                   # Default: master
      [--ignore=one two three]     # List of branches to ignore.
      [--full], [--no-full]        # Show most branch information without cropping.

Show branches which would be deleted (accepts the same arguments as -f):

$ git snip -n

Delete branches already merged to master:

$ git snip -f

Delete branches already merged to master and show more detailed listing of deleted branches:

$ git snip -f --full

Delete branches already merged to master, except staging and production:

$ git snip -f --ignore=staging production

Delete branches already merged to master on /some/repo/path:

$ git snip -f --repo=/some/repo/path

Delete branches already merged to branch_a:

$ git snip -f --target=branch_a

Config file

If you want some arguments to always be set, add a file to the root of the repository with name .git_snip.yml. Specify the default arguments as YAML in the file like this:

full: true
ignore:
  - staging
  - production

The config arguments are overridden when the same arguments are set from command line.

Contributing

  1. Fork it ( https://github.com/htanata/git_snip/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Clean obsolete branches on your git repository safely

Topics

Resources

License

Packages

No packages published

Languages