So I did git stash -u
with my local files.
I got this error:
Unlink of file 'data/somefile.pdf' failed. Should I try again? (y/n)
The reason why I have a PDF file in the repo is because it's a test asset that is required to run unit tests.
Because pressing Y only repeated the error again, I pressed n
.
Immediately after, I did git stash pop
but only a part of the modified files came up.
git stash list
shows some stashes, but popping doesn't work: I get Please commit your changes or stash them before you merge. Aborting
due to a conflict on the same 'data/somefile.pdf'.
Have I lost everything?
So turns out the issue was that the data/somefile.pdf
could not be modified by git because it was opened in another PDF reader application, and I didn't realise that.
Then, git stash -u
didn't actually fail -- it stashed everything, it's just that doing git stash pop
could equally not be completed due to the conflict on the same pdf file.
Closing the app that was preventing the write to the PDF file allowed me to perform git stash pop
and recover the files.
It was a case of panicking, mostly. I'm considering closing/deleting the question, but on the other hand it may be helpful to people panicking over a lost git stash.
And as some user commented, do not use git stash -- I'm planning on learning git worktree
, which seems amazing!