Forked from renkin/gitDeleteLocalOrphanedBranches.sh
Created
February 4, 2024 19:02
-
-
Save sudmed/f0b68ff8d348e0771d484c280f7f7280 to your computer and use it in GitHub Desktop.
Update branch "develop" and delete local orphaned branches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MAIN_BRANCH=${1:-develop} | |
echo | |
echo "Fetching..." | |
git fe | |
echo | |
echo "Switching to $MAIN_BRANCH..." | |
git co $MAIN_BRANCH | |
echo | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment