This was useful for me when we created a new branch for a new major release, but were still working on our current version as well. I cloned our repo again and kept the new project on our new branch, but also wanted to get my stashes there.
git stash show -p > patch
You'll have to specify your stash and name your file whatevery you want. Do this for as all your stashes, and you'll have patch files in your pwd.
cd /new/project/dir
git apply /old/project/dir/patchfile
git stash
While this works, it does not replicate stashes as-is. A stash is a special merge commit of the work tree between the base commit and the index. One way could be to save each as separate patches, checkout the stash first parent, restore the index and work tree from the two patches (I haven't checked this but it could be non-trivial) and finally restore the stash.
This is needed to fully recreate all information from the stash, and if you don't care about that you should at the very least checkout the stash's first parent before restoring to avoid conflicts and keep track of where the stash was created.
This is what I did to fully restore all stashes from one repo to another. If you can't have them on the same computer, you can save the stash tags in a bundle after creating them and copy the refs list and bundle to the target computer.
From the root of the original repo:
stash_
+ the number(s) in the logical stash ref)NB: This requires bash or compatible shell (ksh, zsh should do...) You could also increment a variable, ex
stash_$((i++))
if your shell doesn't support${param//pattern}
Now in the new repo, for each ref: