Created
June 5, 2018 09:56
-
-
Save grncdr/472a7b488c07c0ae7c737905af5daf7f to your computer and use it in GitHub Desktop.
shell script for reviewing your git stashes
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 | |
RETAINED_STASHES="0" | |
REMAINING_STASHES=$(git stash list | wc -l) | |
while true; do | |
if [ "$REMAINING_STASHES" == "0" ]; then | |
echo "All done" | |
break | |
fi | |
git stash show -p "stash@{$RETAINED_STASHES}" | |
read -p "Keep this stash (Y/n)? " choice | |
case "$choice" in | |
n|N) | |
git stash drop "stash@{$RETAINED_STASHES}" | |
;; | |
*) | |
RETAINED_STASHES=$(( $RETAINED_STASHES + 1 )) | |
;; | |
esac | |
REMAINING_STASHES=$(( $REMAINING_STASHES - 1 )) | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment