def prune(options={})
      puts describe_prune(options)

      puts "Fetching latest branches and tags from remotes"
      @git.fetch_all(:prune => true)

      branches = @git.branches(:all => true)

      #Filter by name prefix
      branches = branches.select { |x| x =~ options[:only] } if options[:only]
      branches = branches.reject { |x| x =~ options[:except] } if options[:except]

      #Filter by location (local/remote)
      if options[:local] && !options[:remote]
        branches = branches.local
      elsif options[:remote] && !options[:local]
        branches = branches.remote
      elsif options[:remote] && options[:local]
        raise ArgumentError, "Cannot specify both --local and --remote!"
      end

      #Filter by merge status
      if options[:merged]
        puts "Checking merge status of #{branches.size} branches; please be patient"
        branches = branches.merged(options[:merged])
      end

      old = {}
      branches.each do |branch|
        latest    = @git.log(branch, :tail => 1).first
        timestamp = latest.timestamp
        if timestamp < options[:age] &&
          old[branch] = timestamp
        end
      end

      if old.empty?
        STDERR.puts "No branches found; try different options"
        exit -2
      end

      puts

      all_by_prefix = branches.group_by { |b| b.name.split(NAME_SPLIT_CHARS).first }

      all_by_prefix.each_pair do |prefix, branches|
        old_in_group = branches.select { |b| old.key?(b) }
        next if old_in_group.empty?
        old_in_group = old_in_group.sort { |a, b| old[a] <=> old[b] }
        puts prefix
        puts '-' * prefix.length
        old_in_group.each do |b|
          puts "\t" + b.display(40) + "\t" + time_ago_in_words(old[b])
        end
        puts
      end

      unless options[:force]
        return unless prompt("Delete all #{old.size} branches above?", true)
      end

      old.each do |branch, timestamp|
        branch.delete
        puts "  deleted #{branch}"
      end
    end
def prune(options={})
      puts describe_prune(options)

      puts "Fetching latest branches and tags from remotes"
      @git.fetch_all(:prune => true)

      branches = @git.branches(:all => true)

      #Filter by name prefix
      branches = branches.select { |x| x =~ options[:only] } if options[:only]
      branches = branches.reject { |x| x =~ options[:except] } if options[:except]

      #Filter by location (local/remote)
      if options[:local] && !options[:remote]
        branches = branches.local
      elsif options[:remote] && !options[:local]
        branches = branches.remote
      elsif options[:remote] && options[:local]
        raise ArgumentError, "Cannot specify both --local and --remote!"
      end

      #Filter by merge status
      if options[:merged]
        puts "Checking merge status of #{branches.size} branches; please be patient"
        branches = branches.merged(options[:merged])
      end

      old = {}
      branches.each do |branch|
        latest    = @git.log(branch, :tail => 1).first
        timestamp = latest.timestamp
        if timestamp < options[:age] &&
          old[branch] = timestamp
        end
      end

      if old.empty?
        STDERR.puts "No branches found; try different options"
        exit -2
      end

      puts

      all_by_prefix = branches.group_by { |b| b.name.split(NAME_SPLIT_CHARS).first }

      all_by_prefix.each_pair do |prefix, branches|
        old_in_group = branches.select { |b| old.key?(b) }
        next if old_in_group.empty?
        old_in_group = old_in_group.sort { |a, b| old[a] <=> old[b] }
        puts prefix
        puts '-' * prefix.length
        old_in_group.each do |b|
          puts "\t" + b.display(40) + "\t" + time_ago_in_words(old[b])
        end
        puts
      end

      unless options[:force]
        return unless prompt("Delete all #{old.size} branches above?", true)
      end

      old.each do |branch, timestamp|
        branch.delete
        puts "  deleted #{branch}"
      end
    end
Prune dead branches from the repository.

 @option options [Time] :age Ignore branches whose HEAD commit is newer than this timestamp
 @option options [Regexp] :except Ignore branches matching this pattern
 @option options [Regexp] :only Consider only branches matching this pattern
 @option options [Boolean] :local Consider only local branches
 @option options [Boolean] :remote Consider only remote branches
 @option options [String] :merged Consider only branches that are fully merged into this branch (e.g. master)