Last active
December 23, 2021 08:43
-
-
Save stefanofiorentino/ed6bd40424016054e2a090a71cd460d4 to your computer and use it in GitHub Desktop.
git script to add to $PATH to be launched by `git gone` or `git gone --force` (it only print commands to issue)
This file contains 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 | |
git fetch | |
REMOTE=origin | |
if [ $# -ge 1 ]; then | |
REMOTE=$1 | |
fi | |
echo "Pruning ${REMOTE}: $#" | |
if [[ $* == *--force* ]] | |
then | |
git remote prune ${REMOTE} && git branch -vv | cut -c 3- | grep ': gone]' | awk '{print $1}' | xargs -n1 -r echo git branch -D | |
else | |
git remote prune ${REMOTE} && git branch -vv | cut -c 3- | grep ': gone]' | awk '{print $1}' | xargs -n1 -r echo git branch -d | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment