Skip to content

Instantly share code, notes, and snippets.

@grncdr
Created June 5, 2018 09:56
Show Gist options
  • Save grncdr/472a7b488c07c0ae7c737905af5daf7f to your computer and use it in GitHub Desktop.
Save grncdr/472a7b488c07c0ae7c737905af5daf7f to your computer and use it in GitHub Desktop.
shell script for reviewing your git stashes
#!/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