Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save sudmed/f0b68ff8d348e0771d484c280f7f7280 to your computer and use it in GitHub Desktop.

Select an option

Save sudmed/f0b68ff8d348e0771d484c280f7f7280 to your computer and use it in GitHub Desktop.

Revisions

  1. @renkin renkin revised this gist Dec 16, 2021. No changes.
  2. @renkin renkin revised this gist Sep 29, 2021. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions gitDeleteLocalOrphanedBranches.sh
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,19 @@
    #!/bin/bash

    MAIN_BRANCH=${1:-develop}

    echo
    echo "Fetching..."
    git fe

    echo
    echo "Switching to develop..."
    git co develop
    echo "Switching to $MAIN_BRANCH..."
    git co $MAIN_BRANCH

    echo
    echo "Pulling develop..."
    echo "Pulling $MAIN_BRANCH..."
    git pull

    echo
    echo "Deleting local orphaned branches..."
    git branch -vv | grep ': gone]'| grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -d
    git branch -vv | grep ': gone]' | grep -v '^\*' | awk '{ print $1; }' | xargs -r git branch -d
  3. @renkin renkin created this gist Feb 25, 2021.
    17 changes: 17 additions & 0 deletions gitDeleteLocalOrphanedBranches.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/bin/bash

    echo
    echo "Fetching..."
    git fe

    echo
    echo "Switching to develop..."
    git co develop

    echo
    echo "Pulling develop..."
    git pull

    echo
    echo "Deleting local orphaned branches..."
    git branch -vv | grep ': gone]'| grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -d