Reputation: 2245
I have been using PhpStorm and recently stashed a load of my changes. At some point after that, my PC profile became corrupt and had to be rebuilt.
Now that I have a new PC profile, PhpStorm is not showing my stashed changes.
Is there any way I can get them back?
Upvotes: 31
Views: 60397
Reputation: 848
The actual data stashed by "git stash
" (i.e. the current version of the working tree and the contents of .git/index
) is stored as two commit trees.
One commit tree contains a snapshot of the current state of the working tree. There are some tricky bits here, see below.
The other commit tree, I've been told, is used to store a snapshot of the contents of .git/index
at the time of the stash. I haven't looked into this deeply enough (yet) to understand how the one is translated into the other.
.git/refs/stash
contains the hash value for the commit tree that the stash created.
.git/logs/refs/stash
contains a reflog-like chunk of metadata about the stashes before the one in .git/refs/stash
.
.git/index
holds a list of entries for each file in the working tree. Those entries contain the full path and filename and also cached metadata about the file, both filesystem metadata and git-related metadata.
"git add
" both adds a copy of a file to the object store, and sets the staging flag for that file in .git/index.
For "git stash
" to create a commit tree, files that have been changed (edited) but not yet staged with "git add
" have to be added to the object store. "git stash
" does this by building a temporary index file.
Upvotes: 19
Reputation: 36319
From the docs, the latest one is stored in ./.git/refs/stash
while older ones are in the reflog
of that ref
.
As an aside, I've found it's a bad practice to maintain a regular use of git stash. Generally, prefer many small commits on a feature branch. This way you rarely have to stash and when you do it's very little stored as such. I generally stash only when I need to touch something away for a few minutes, and then apply when I'm done looking at something.
https://git-scm.com/docs/git-stash
Upvotes: 29
Reputation: 9888
All are stored in .git/refs/stash
. git stash
saves stashes indefinitely, and all of them are listed by git stash list
.
Please note that dropping or clearing the stash will remove it from the stash list, but you might still have unpruned nodes with the right data lying around.
Upvotes: 6