Skip to content

Instantly share code, notes, and snippets.

@jsonberry
Last active August 8, 2022 14:42
Show Gist options
  • Save jsonberry/426766b9cf732e9aad98af3eab3de90c to your computer and use it in GitHub Desktop.
Save jsonberry/426766b9cf732e9aad98af3eab3de90c to your computer and use it in GitHub Desktop.

Revisions

  1. jsonberry revised this gist Nov 14, 2017. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions purge_branches.sh
    Original file line number Diff line number Diff line change
    @@ -7,10 +7,9 @@ git remote prune origin
    // List all local branches that were merged into master, explicitly exclude master from that list
    git branch --merged master | grep -v 'master'

    /**
    * Delete local branches
    * Each command does not delete master
    *
    /*
    Delete local branches
    Each command does not delete master
    */

    // Delete all local branches that were merged into master
  2. jsonberry revised this gist Oct 31, 2017. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions purge_branches.sh
    Original file line number Diff line number Diff line change
    @@ -8,16 +8,16 @@ git remote prune origin
    git branch --merged master | grep -v 'master'

    /**
    * Purge local branches
    * Each command does not purge master
    * Delete local branches
    * Each command does not delete master
    *
    */

    // Purge all local branches that were merged into master
    // Delete all local branches that were merged into master
    git branch --merged master | grep -v 'master' | xargs git branch -d

    // Safe purge of all local branches (branches not merged into master will not get purged)
    // Safe deletion of all local branches (branches not merged into master will not get purged)
    git branch | grep -v 'master' | xargs git branch -d

    // Force purge of all local branches
    // Force delete of all local branches
    git branch | grep -v 'master' | xargs git branch -D
  3. jsonberry revised this gist Oct 31, 2017. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions purge_branches.sh
    Original file line number Diff line number Diff line change
    @@ -7,10 +7,11 @@ git remote prune origin
    // List all local branches that were merged into master, explicitly exclude master from that list
    git branch --merged master | grep -v 'master'

    /*
    * Purge local branches
    * Each command does not purge master
    */
    /**
    * Purge local branches
    * Each command does not purge master
    *
    */

    // Purge all local branches that were merged into master
    git branch --merged master | grep -v 'master' | xargs git branch -d
  4. jsonberry revised this gist Jan 31, 2017. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions purge_branches.sh
    Original file line number Diff line number Diff line change
    @@ -8,10 +8,8 @@ git remote prune origin
    git branch --merged master | grep -v 'master'

    /*
    *
    * Purge local branches
    * Each command does not purge master
    *
    */

    // Purge all local branches that were merged into master
  5. jsonberry revised this gist Jan 31, 2017. 1 changed file with 13 additions and 3 deletions.
    16 changes: 13 additions & 3 deletions purge_branches.sh
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,18 @@ git remote prune origin
    // List all local branches that were merged into master, explicitly exclude master from that list
    git branch --merged master | grep -v 'master'

    // Remove all local branches that were merged into master, do not include master
    /*
    *
    * Purge local branches
    * Each command does not purge master
    *
    */

    // Purge all local branches that were merged into master
    git branch --merged master | grep -v 'master' | xargs git branch -d

    // Remove all local branches _not_ merged into master, do not include master
    git branch | grep -v 'master' | xargs git branch -d
    // Safe purge of all local branches (branches not merged into master will not get purged)
    git branch | grep -v 'master' | xargs git branch -d

    // Force purge of all local branches
    git branch | grep -v 'master' | xargs git branch -D
  6. jsonberry created this gist Jan 26, 2017.
    14 changes: 14 additions & 0 deletions purge_branches.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    // List all remotely tracked branches that do not exist in the remote repo
    git remote prune origin --dry-run

    // Prune all remotely tracked branches that do not exist in the remote repo
    git remote prune origin

    // List all local branches that were merged into master, explicitly exclude master from that list
    git branch --merged master | grep -v 'master'

    // Remove all local branches that were merged into master, do not include master
    git branch --merged master | grep -v 'master' | xargs git branch -d

    // Remove all local branches _not_ merged into master, do not include master
    git branch | grep -v 'master' | xargs git branch -d