Skip to content

Instantly share code, notes, and snippets.

@IrishPrime
Created October 3, 2017 15:31
Show Gist options
  • Select an option

  • Save IrishPrime/3bdb9e4dde74b2e68c74d29801a6a76a to your computer and use it in GitHub Desktop.

Select an option

Save IrishPrime/3bdb9e4dde74b2e68c74d29801a6a76a to your computer and use it in GitHub Desktop.

Revisions

  1. IrishPrime created this gist Oct 3, 2017.
    12 changes: 12 additions & 0 deletions git-cleanup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/bin/bash

    # Delete remote branches which have been merged into master, excluding the
    # current branch, then remove local branches pointing to remote branches which
    # have been deleted.

    # Test
    git branch -r --merged master | grep -v -e $(git symbolic-ref --short HEAD) -e master | sed 's/origin\///'

    # Delete
    # git branch -r --merged master | grep -v -e $(git symbolic-ref --short HEAD) -e master | sed 's/origin\///' | xargs -n 1 git push --delete origin
    # git fetch --prune