I'm using git stash push -a
in a script to save uncommitted changes and then sometime later run git stash pop
in the same script to restore the stashed changes. I've run into a problem in which git stash push -a
occasionally reports "No local changes to save" and no no stash is created. This causes the subsequent git stash pop
to fail with exit code 1. Is there a way I can detect when git stash push -a
reports "No local changes to save" so that I know that no stash is created (short of checking the git stash push -a
output) and thus not perform the git stash pop
?
Botje's "cheeky suggestion" of creating a temporary file so that git stash push -a
has at least one file to stash worked for me. Just remember to delete the temporary file after running git stash pop
.