Created
December 23, 2020 16:09
-
-
Save dougharris/a5a1f6a5155ac6c72bc0ae081c1c4cf4 to your computer and use it in GitHub Desktop.
Script for exporting 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 | |
STASH_DIR="${HOME}/src/stash-patches" | |
PROJECT=$(basename $(pwd)) | |
mkdir -p "${STASH_DIR}/${PROJECT}" | |
git stash list | while read -r ref stash | |
do | |
name=$(echo $stash | awk -F': ' '{printf("%s", $2);}' | tr -c '[:alnum:]_-' '-' | tr -s '-') | |
full_path="${STASH_DIR}/${PROJECT}/${name}" | |
echo "Writing stash '${name}' to ${full_path}" | |
git stash show "${ref/:/}" -p > "${full_path}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment