-
-
Save valsaven/ea71cf86569d55cdb57afaef610a560b to your computer and use it in GitHub Desktop.
Selectively bulk delete git stash files.
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 | |
if [ ! -d ".git" ]; then | |
echo "Not a git Directory" | |
exit 1 | |
fi | |
function getStashesToRemove { | |
git stash list | while read -r line; | |
do | |
read -p "remove branch: $line (y/N)?" answer </dev/tty; | |
case "$answer" in y|Y) | |
echo "$line"; | |
esac; | |
done | |
} | |
REFS=($(getStashesToRemove | cut -d ':' -f 1)) | |
for (( idx=${#REFS[@]}-1 ; idx>=0 ; idx-- )) ; do | |
echo "Removing ${REFS[idx]}" | |
git stash drop "${REFS[idx]}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment