Skip to content

Instantly share code, notes, and snippets.

@yrtimiD
Last active February 7, 2024 13:08
Show Gist options
  • Save yrtimiD/93fb3b5527ba1c8fd69745ed2735de22 to your computer and use it in GitHub Desktop.
Save yrtimiD/93fb3b5527ba1c8fd69745ed2735de22 to your computer and use it in GitHub Desktop.
Migrate stashes between git repos
refs=$(git stash list|cut -d: -f1)
for ref in $refs; do
patchname=`git show -s --pretty=%f $ref`.patch
echo $patchname
git stash show -p $ref > $patchname;
done
#set -x
for patch in *.patch; do
echo "Importing $patch"
git apply $patch
if [ $? -eq 0 ]; then
git stash push -m "${patch/%.patch/}"
if [ $? -eq 0 ]; then
echo "Deleting $patch"
rm $patch
fi
else
echo "Skipping $patch"
fi
read -n 1 -p "next?"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment